Skip to content

Change internal types in individual files to be private. Use TypeAlias in code where types are declared. #61504

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Dr-Irv
Copy link
Contributor

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

After introducing TypeAlias in _typing.py, goal of this PR is to use it in any other source files that are creating types in this way. Also, make all of those types private.

I believe that I caught them all via some searching, but may have missed a few. Couldn't find a rule that enforces use of TypeAlias. Note that in 3.12, the recommendation is to do a type declaration, which is probably why there isn't such a rule.

@mroeschke mroeschke added the Typing type annotations, mypy/pyright type checking label May 27, 2025
@@ -71,7 +72,7 @@
from pandas.core.resample import Resampler
from pandas.core.window.rolling import BaseWindow

ResType = dict[int, Any]
_ResType: TypeAlias = dict[int, Any]
Copy link
Member

Choose a reason for hiding this comment

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

Is this idea of making these lead with a starting _ is to they are marked as "private"? Should they instead just be moved to _typing.py with other defined "private" annotations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this idea of making these lead with a starting _ is to they are marked as "private"? Should they instead just be moved to _typing.py with other defined "private" annotations?

The difference with the annotations in _typing.py is that many (but not all) are used in more than one pandas module. For the ones that are marked private in this PR, they are only used locally within that module.

I'm also going to be doing an MR to make more of the ones in _typing.py public.

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