Skip to content
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

[REDO] CLN: core/dtypes/cast.py::maybe_downcast_to_dtype #37126

Merged
merged 11 commits into from
Oct 17, 2020

Conversation

arw2019
Copy link
Member

@arw2019 arw2019 commented Oct 15, 2020

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

xref #37050 (comment)

The combination of #37050 and #37024 generated a mypy complaint. This PR is resubmission of #37050 with the correct type hint.

cc @simonjayhawkins

@arw2019 arw2019 force-pushed the maybe_downcast_to_dtype_cleanup branch from 1c9bfe8 to a0a39ff Compare October 15, 2020 12:33
@@ -133,7 +134,7 @@ def is_nested_object(obj) -> bool:
return False


def maybe_downcast_to_dtype(result, dtype: Dtype):
def maybe_downcast_to_dtype(result, dtype: Union[str, np.dtype]):
Copy link
Contributor

Choose a reason for hiding this comment

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

this is not correct, DtypeObj right

Copy link
Member Author

Choose a reason for hiding this comment

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

has to be a numpy type or str according to mypy. When I put it DtypeObj mypy errors:

pandas/core/dtypes/cast.py:180: error: Item "ExtensionDtype" of "Union[Any, ExtensionDtype]" has no attribute "freq"  [union-attr]

@jreback jreback added the Typing type annotations, mypy/pyright type checking label Oct 16, 2020
@arw2019 arw2019 force-pushed the maybe_downcast_to_dtype_cleanup branch from a0a39ff to 048508b Compare October 17, 2020 00:59
@jreback jreback added this to the 1.2 milestone Oct 17, 2020
@jreback jreback merged commit 98011a9 into pandas-dev:master Oct 17, 2020
@jreback
Copy link
Contributor

jreback commented Oct 17, 2020

thanks @arw2019

@jreback jreback added the Dtype Conversions Unexpected or buggy dtype conversions label Oct 17, 2020
JulianWgs pushed a commit to JulianWgs/pandas that referenced this pull request Oct 26, 2020
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dtype Conversions Unexpected or buggy dtype conversions Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants