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

Ignoring import-private-name (PLC2701) for _typeshed import #15295

Open
Avasam opened this issue Jan 6, 2025 · 2 comments
Open

Ignoring import-private-name (PLC2701) for _typeshed import #15295

Avasam opened this issue Jan 6, 2025 · 2 comments
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule

Comments

@Avasam
Copy link
Contributor

Avasam commented Jan 6, 2025

_typeshed exposes plenty of very useful type aliases and protocols. A lot of those are even marked as stable by typeshed maintainers.
_typeshed imports can only be used in annotations and type-stubs.

For these reasons, I don't think import-private-name (PLC2701) brings value in applying to the _typeshed import. I'd like to see this rule ignore that import. Or to have a way to configure names and/or modules I'd like ignored.

Ruff: 0.8.5

@MichaReiser MichaReiser added rule Implementing or modifying a lint rule needs-decision Awaiting a decision from a maintainer labels Jan 6, 2025
@MichaReiser
Copy link
Member

For reference: The documentation of the _typeshed module can be found here

I'm more leaning towards an option (e.g. an allowlist of modules where private names are allowed), if we want to change this at all as this module is in a gray area where it is somewhat public but also not entirely stable. Another alternative is to remove it from PLC2701 and introduce a new rule specifically to _typeshed.

@Avasam
Copy link
Contributor Author

Avasam commented Jan 6, 2025

An allowlist would be my go-to solution, whether or not you have it default to include _typeshed. It's more flexible for the end user and their cases where they know they have to repeatedly import a private name or from a private module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-decision Awaiting a decision from a maintainer rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

2 participants