Skip to content

move private imports from testing into tests/__init__.py #1205

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 1 commit into from
Apr 29, 2025

Conversation

Dr-Irv
Copy link
Collaborator

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

In preparation for an eventual change in pyright that would ban private imports, I have moved the private imports for the tests into tests/__init__.py.

Also will be working to make some of the current private imports public as reflected in the discussion here:
pandas-dev/pandas#55231 (comment)

@Dr-Irv Dr-Irv requested a review from twoertwein April 27, 2025 23:50
@twoertwein
Copy link
Member

Thank you @Dr-Irv ! Just had a quick look: the changes look great! I will review/approve it later today.

I assume we are still allowed to import from _typing inside the stubs?

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Apr 28, 2025

I assume we are still allowed to import from _typing inside the stubs?

Yes. The issue that came up with pyright (and they removed the feature in 1.1.400 at my request - but want to put it back), is that if you installed pandas-stubs and had code that did an import from pandas._typing, it would report that as an import from a private module.

So this PR is "centralizing" all of the imports from the private module, except for ones that I am proposing to put somewhere else.

Copy link
Member

@twoertwein twoertwein left a comment

Choose a reason for hiding this comment

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

Looks great and the new pyright feature seems also useful to avoid using private APIs! I wouldn't be surprised if some people directly import from _libs.

@twoertwein twoertwein merged commit f5fd35f into pandas-dev:main Apr 29, 2025
13 checks passed
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