-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
reportPrivateImportUsage error on public-looking symbol defined with relative import #2639
Comments
This is a "py.typed" library, so it is expected to follow the rules in this documentation: https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface. By default, an imported symbol is considered private (not re-exported). If the intent is to re-export the imported symbol, it needs to either be included in an I recommend filing a bug or a PR for this library. While you're waiting for a fix, you can disable the |
Hey @erictraut They're confused about this specific section from the linked documentation:
I think this is intended to read :
as symbol "A" is not exposed by the latter example. Assuming that document is correct, these functions should be considered part of the public interface. |
The import statement |
Great, thanks for explaining! Would you be willing to update or accept an update that changes the language to clarify that? For example
|
If I may add my input here, I think the "likewise" might be the confusing part. What about:
assuming that is the correct interpretation. |
Thanks for the suggestions. The word "likewise" was meant to avoid repeating the phrase "unless the name begins with an underscore", but I can see why it might lead to confusion. The document intentionally doesn't use the term "public" (based on previous feedback). I've attempted to take into account your feedback and improve the wording. |
Thanks a bunch! Appreciate your timely and considerate responses. |
This makes: ```python import jinjax # And then using... jinjax.JinjaX # Or some other symbol ``` behave properly for type checkers like pyright by following the PEP561/[type information in libraries spec](<https://typing.readthedocs.io/en/latest/spec/distributing.html#type-information-in-libraries>). Without the change, pyright reports: `error: "JinjaX" is not exported from module "jinjax" (reportPrivateImportUsage)` microsoft/pyright#2639 (comment)
Describe the bug
Prefect defines a symbol with
from .kubernetes import ECSRun
insrc/prefect/run_configs/__init__.py
, but I get a reportPrivateImportUsage error from pyright when I havefrom prefect.run_configs import ECSRun
in my application.To Reproduce
pip install prefect
test.py
, writefrom prefect.run_configs import ECSRun
pyright test.py
Expected behavior
My understanding from https://github.com/microsoft/pyright/blob/main/docs/typed-libraries.md#library-interface is that I should not be getting an error because this is an implicitly public symbol.
Screenshots or Code
VS Code extension or command-line
Commandline version 1.1.191
Additional context
Trying to fix these errors for prefect as a whole in PrefectHQ/prefect#5174, but this is confusing me.
The text was updated successfully, but these errors were encountered: