Skip to content
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

Extend reportPrivateImportUsage to report use of symbols imported from private submodules in a "py.typed" library #9008

Open
erictraut opened this issue Sep 16, 2024 Discussed in #9004 · 0 comments
Labels
enhancement request New feature or request

Comments

@erictraut
Copy link
Collaborator

Discussed in #9004

Originally posted by Delgan September 16, 2024
Hi.

I've read the docs about Library interface but I can't understand why isn't pyright reporting an error when I import private modules.

Consider first installing a third-party library like pydantic:

pip install pydantic==2.9.1

Then asking pyright to analyze the following file in "strict" mode:

# pyright: strict
import pydantic._migration

print(pydantic._migration.MOVED_IN_V2)

Because I'm importing and using _migration which is supposed to be a private module, I would expect an error such as reportPrivateUsage or reportPrivateImportUsage. However, the output is (for version 1.1.380):

0 errors, 0 warnings, 0 informations 

Is that intentional design? I understand that for unit tests within the library, it's preferable for library authors to be able to import a private module (and test some internal functions). But shouldn't this be forbidden for a library user?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant