Skip to content

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
@Dr-Irv Dr-Irv deleted the change_imports branch September 11, 2025 14:35
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