Skip to content

TYP: fix ignores #40452

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

Merged
merged 16 commits into from
Mar 17, 2021
Merged

TYP: fix ignores #40452

merged 16 commits into from
Mar 17, 2021

Conversation

jbrockmendel
Copy link
Member

No description provided.

def ensure_dtype_can_hold_na(dtype: ExtensionDtype) -> ExtensionDtype:
...


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could perhaps create a _DtypeObjT typvar (local to the module if we don't need elsewhere) instead of an overload here since ensure_dtype_can_hold_na is type-preserving

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i considered that and ended up not pulling the trigger, would be OK with it if you feel strongly about it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you feel strongly about it

I wouldn't block on this, so i'll leave it to you.

I won't be able to fully review this PR till tomorrow, so the comments so far are just some bits that stood out.

) -> Union[np.ndarray, DatetimeArray]:
...


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with these Literal[True]/Literal[False] may also need to add an extra bool case. ie. duplicate the function signature as an additional overload (follow-on ok as may not be needed if this is internal) see #40200 and #40197

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may not be needed if this is internal

yah this shouldnt be user-facing

cls, result, dtype=dtype # type: ignore[arg-type]
)
if isinstance(dtype, ExtensionDtype):
if not is_categorical_dtype(dtype) and dtype.kind != "M":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic has changed here slightly. is there a latent bug here that needs a test.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking some more, maybe the type annotations for maybe_downcast_to_dtype are incorrect?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this is only called from one place and that is with numeric_only=True (ought to remove that kwarg) and the two cases excluded here dont have is_numeric_dtype(dtype), the behavior will end up being the same before and after

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking some more, maybe the type annotations for maybe_downcast_to_dtype are incorrect?

it does look sketchy, yah

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the two cases excluded here dont have is_numeric_dtype(dtype), the behavior will end up being the same before and after

so it does.

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. making good progress clearing down the numpy related ignores. Thanks @jbrockmendel .

@@ -1471,7 +1463,7 @@ def soft_convert_objects(


def convert_dtypes(
input_array: AnyArrayLike,
input_array: ArrayLike,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now inconsistent with the docstring

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Mar 16, 2021
@simonjayhawkins simonjayhawkins added this to the 1.3 milestone Mar 16, 2021
@simonjayhawkins simonjayhawkins merged commit 9664284 into pandas-dev:master Mar 17, 2021
@simonjayhawkins
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the typ-core-3 branch March 17, 2021 14:09
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants