Skip to content

TYP/CLN: small cleanups from flake-pyi #47850

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 4 commits into from
Jul 26, 2022
Merged

TYP/CLN: small cleanups from flake-pyi #47850

merged 4 commits into from
Jul 26, 2022

Conversation

twoertwein
Copy link
Member

Most of these changes are:

Y041 Use "float" instead of "int | float" (see "The numeric tower" in PEP 484)

flake8-pyi would probably find similar issues in the in-line annotations but flake8-pyi does at the moment only support pyi files.

Copy link
Contributor

@Dr-Irv Dr-Irv left a comment

Choose a reason for hiding this comment

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

Assuming the CI succeeds, I approve.

@mroeschke
Copy link
Member

Hmm I understand from a typing cleanup and numeric inheritance perspective this makes sense, but I find this a little less explicit (especially if the typing is exposed in documentation(?)).

For example, one might think they need to unnecessarily cast an int to float or it's less clear from the typing if a function only accepts a float.

I could be convinced otherwise. Just open to thoughts on those points.

@mroeschke mroeschke added the Typing type annotations, mypy/pyright type checking label Jul 26, 2022
@twoertwein
Copy link
Member Author

Maybe two reasons why it might be okay:

  • the type annotations are not included in the doc-string (only myy&pyright see them)
  • all of the type-stubs in typeshed do the same (flake8-pyi is developed by the "typeshe people")

@mroeschke mroeschke added this to the 1.5 milestone Jul 26, 2022
Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

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

Thanks those are fair points. I'm okay with these changes then.

@mroeschke mroeschke merged commit e12b318 into pandas-dev:main Jul 26, 2022
@twoertwein twoertwein deleted the flakepyi branch September 10, 2022 01:38
@jbrockmendel
Copy link
Member

FWIW i just stumbled on this bc I saw "int" was missing from the annotation for validate_periods

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.

4 participants