Skip to content

Add py.typed #260

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
Sep 4, 2022
Merged

Add py.typed #260

merged 4 commits into from
Sep 4, 2022

Conversation

twoertwein
Copy link
Member

ABCExtensionArray and ABCSeries did not exist in the stubs but this error might have been hidden because the pandas implementation provides it.

@twoertwein
Copy link
Member Author

A much easier fix would be to simply have pandas-stubs/py.typed then we don't need renaming.

@Dr-Irv I now you removed it at some point because of a bug(?) in pyright. Is it now safe to enable it again?

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Sep 4, 2022

A much easier fix would be to simply have pandas-stubs/py.typed then we don't need renaming.

@Dr-Irv I now you removed it at some point because of a bug(?) in pyright. Is it now safe to enable it again?

Don't know. If that would work, I'd prefer it over having to rename pandas during testing. Can you try that?

@twoertwein
Copy link
Member Author

Don't know. If that would work, I'd prefer it over having to rename pandas during testing. Can you try that?

If I remove ABCExtensionArray and just have a py.typed, mypy/pyright notice the error :)

ABCSeries = type[Series]
ABCDataFrame = type[DataFrame]

ABCExtensionArray = type[ExtensionArray]
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically need only ABCExtensionArray and ABCSeries for the current stubs.

@twoertwein twoertwein changed the title Hide pandas implementation during type checking Add py.typed Sep 4, 2022
Copy link
Collaborator

@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.

I think we should have py.typed with the word partial in it.

@twoertwein
Copy link
Member Author

https://peps.python.org/pep-0561/

Many stub packages will only have part of the type interface for libraries completed, especially initially. For the benefit of type checking and code editors, packages can be “partial”. This means modules not found in the stub package SHOULD be searched for in parts four and five of the module resolution order above, namely inline packages and typeshed.

If we add partial, mypy does not find the missing ABCExtensionArray (and users's type checkers will also fallback on the pandas implementation). While pandas-stubs is not complete, I would slightly favor marking it as complete, so that people report any missing annotations to make pandas-stub more complete.

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Sep 4, 2022

If we add partial, mypy does not find the missing ABCExtensionArray (and users's type checkers will also fallback on the pandas implementation). While pandas-stubs is not complete, I would slightly favor marking it as complete, so that people report any missing annotations to make pandas-stub more complete.

OK, I'm fine with that.

Copy link
Collaborator

@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.

thanks @twoertwein

@Dr-Irv Dr-Irv merged commit fbe591f into pandas-dev:main Sep 4, 2022
@twoertwein twoertwein deleted the implementation branch September 21, 2022 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants