Skip to content

align typing with pandas source #1219

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 2 commits into from
May 19, 2025
Merged

Conversation

Dr-Irv
Copy link
Collaborator

@Dr-Irv Dr-Irv commented May 18, 2025

Possibly closes #128

I went through the current pandas source in pandas/_typing.py and separated the types declared there from the "private" types only used in the stubs, which now appear at the bottom of the file, and added documentation where appropriate to indicate where things are different.

Unclear whether the "private" types in the stubs should all be preceded by underscores. They are imported from pandas/_typing, so that makes them private anyway. When I wrote #128, I suggested to make them all private. Now that I have more experience with typing, I don't think it's necessary.

By doing this, I have a list of types that should be "public" which will eventually go in pandas.api.typing.aliases . That will then allow me to work on pandas-dev/pandas#55231

Asking for opinions of @loicdiridollou and a review/approval/merge from @twoertwein

@loicdiridollou
Copy link
Member

Great job in here, I think this is a major improvement. Hopefully that can unblock the other issue in pandas repo.
Added a few comments about some types being defined in files instead of _typing.pyi.
Not totally sure what is the exact direction that would fit the team at pandas but this is a ton of work already here and we can continue to use the stubtest to clean up some of the function signatures that have drifted from the pandas implementaion.

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented May 18, 2025

Added a few comments about some types being defined in files instead of _typing.pyi.

For now, I'd rather mirror what is in the pandas source, where both of those types are defined in the respective files. That's where I picked them up from. If someone really wants access to them, they can import them from those files, which are not in private modules.

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented May 18, 2025

@twoertwein thanks for the review. I've pushed a new version that addresses your comments (and commented on a few other comments where I didn't make a change)

@twoertwein twoertwein merged commit 93a9e11 into pandas-dev:main May 19, 2025
13 checks passed
@twoertwein
Copy link
Member

Thanks @Dr-Irv !

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.

CLEAN: Reconcile types in pandas._typing.py and pandas-stubs._typing.pyi
3 participants