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

PYI024 is noisy #165

Open
jaraco opened this issue Mar 4, 2025 · 3 comments
Open

PYI024 is noisy #165

jaraco opened this issue Mar 4, 2025 · 3 comments

Comments

@jaraco
Copy link
Owner

jaraco commented Mar 4, 2025

This rule turns out to be noisy (PYI024 in particular). It requires re-writing all namedtuples to typing.NamedTuples and can't be fixed mechanically.

Originally posted by @jaraco in #160 (comment)

jaraco added a commit to jaraco/jaraco.vcs that referenced this issue Mar 4, 2025
@jaraco
Copy link
Owner Author

jaraco commented Mar 4, 2025

I've only spot-checked a few repos, and already I've encountered three instances of this check failing.

I'm not sure the check should be disabled, but it sure is inconvenient to have it right now.

jaraco added a commit to jaraco/jaraco.versioning that referenced this issue Mar 4, 2025
@Avasam
Copy link
Contributor

Avasam commented Mar 4, 2025

This check in particular aims for typed code (function-based namedtuples can't have their attributes typed). Given there's a lot of skeleton-based projects that can only afford very basic type-checking, or doesn't even pass basic mypy yet. It would make sense to leave changing collection.namedtuple to typing.NameTuple based on usage (meaning when typed code encounters an untyped namedtuple), rather than on definition ahead of time.

That would be my reasoning for disabling PYI024 at the skeleton level.

That being said, I wonder if it could suggest an autofix where the attributes are typed as Any.

@Avasam
Copy link
Contributor

Avasam commented Mar 4, 2025

idk if mypy reports it, but pyright does with reportUntypedNamedTuple. So there's already some overlap with type checkers there.

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

No branches or pull requests

2 participants