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

Define __all__ to re-export classes #99

Merged
merged 1 commit into from
Oct 19, 2024
Merged

Conversation

jacobcheatley
Copy link
Contributor

This makes:

import jinjax

# And then using...
jinjax.JinjaX
# Or some other symbol

behave properly for type checkers like pyright by conforming to the PEP561 / type information in libraries spec. Linters also stop complaining, so you can remove the #noqa.

Without the change, pyright reports: error: "JinjaX" is not exported from module "jinjax" (reportPrivateImportUsage)

This can be worked around by ignoring the reportPrivateImportUsage rule, but it's nice to have.

An alternative to setting __all__ would be redundant aliases (e.g. from .jinjax import JinjaX as JinjaX) but I figured those were less nice.

microsoft/pyright#2639 (comment)

@jpsca jpsca merged commit 6cb8383 into jpsca:main Oct 19, 2024
3 of 4 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