-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: mostly core.arrays, some core.indexes #40545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jbrockmendel
commented
Mar 20, 2021
- closes #xxxx
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axis typing
@@ -952,7 +952,7 @@ def freqstr(self): | |||
return self.freq.freqstr | |||
|
|||
@property # NB: override with cache_readonly in immutable subclasses | |||
def inferred_freq(self): | |||
def inferred_freq(self) -> Optional[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we have a Freq typing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do, but this is more specific
pandas/core/arrays/numpy_.py
Outdated
@@ -205,12 +205,12 @@ def _values_for_factorize(self) -> Tuple[np.ndarray, int]: | |||
# ------------------------------------------------------------------------ | |||
# Reductions | |||
|
|||
def any(self, *, axis=None, out=None, keepdims=False, skipna=True): | |||
def any(self, *, axis=None, out=None, keepdims: bool = False, skipna: bool = True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can type Axis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
|
||
def take( | ||
self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs | ||
self, indices, axis: int = 0, allow_fill: bool = True, fill_value=None, **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Axis includes str that is only for Series/DataFrame
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are correct as-is, but if for some reason theyre a deal-breaker ill revert to push this through
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no its fine, i get that these have to be ints
""" return the size of my table in bytes """ | ||
overhead = 4 * sizeof(uint32_t) + 3 * sizeof(uint32_t*) | ||
for_flags = max(1, self.table.n_buckets >> 5) * sizeof(uint32_t) | ||
for_pairs = self.table.n_buckets * (sizeof({{dtype}}_t) + # keys | ||
sizeof(Py_ssize_t)) # vals | ||
return overhead + for_flags + for_pairs | ||
|
||
def get_state(self): | ||
def get_state(self) -> dict[str, int]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be consistent about this pattern, IIRC we use Dict[str, int]
? cc @simonjayhawkins ok either way, we should have a rule and convert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC there was no objection to using the new syntax, just not ready to convert all existing annotations yet. I recall a discussion about this and I _think_the outcome was that we would wait till closer to 1.3 to use pyupgrade to reduce the potential conflicts with backports but I can't find the relevant discussion. @MarcoGorelli
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was #39930
Removing --keep-runtime-typing
will upgrade to newer syntax in files with from __future__ import annotations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh yes. it was because mypy in 1.2.x is on an older version. #39538 (review)
nbd. can fixup the backports if necessary to use the older syntax. so imo can do whenever.
keepdims=False, | ||
skipna=True, | ||
keepdims: bool = False, | ||
skipna: bool = True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can return type all of theses i guess as Union[Scalar, ndarray] .....
|
||
def take( | ||
self, indices, axis=0, allow_fill=True, fill_value=None, **kwargs | ||
self, indices, axis: int = 0, allow_fill: bool = True, fill_value=None, **kwargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no its fine, i get that these have to be ints
cool one comment above for potential followon |