Extend `reportPrivateImportUsage` to report use of symbols imported from private submodules in a "py.typed" library
Discussed in https://github.com/microsoft/pyright/discussions/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?