[ty] Emit invalid-named-tuple on namedtuple classes that have field names starting with underscores#21697
Merged
AlexWaygood merged 1 commit intomainfrom Dec 1, 2025
Merged
Conversation
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-12-01 11:33:22.595865886 +0000
+++ new-output.txt 2025-12-01 11:33:26.305906382 +0000
@@ -752,6 +752,7 @@
namedtuples_define_class.py:48:22: error[too-many-positional-arguments] Too many positional arguments: expected 4, got 5
namedtuples_define_class.py:49:23: error[unknown-argument] Argument `other` does not match any known parameter
namedtuples_define_class.py:69:20: error[too-many-positional-arguments] Too many positional arguments: expected 3, got 4
+namedtuples_define_class.py:76:5: error[invalid-named-tuple] NamedTuple field `_y` cannot start with an underscore
namedtuples_define_class.py:86:5: error[invalid-named-tuple] NamedTuple field without default value cannot follow field(s) with default value(s): Field `latitude` defined here without a default value
namedtuples_define_class.py:121:1: error[type-assertion-failure] Type `Property[int | float]` does not match asserted type `Property[float]`
namedtuples_define_class.py:122:1: error[type-assertion-failure] Type `int | float` does not match asserted type `float`
@@ -1039,4 +1040,4 @@
typeddicts_usage.py:28:17: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
typeddicts_usage.py:28:18: error[invalid-key] Unknown key "title" for TypedDict `Movie`: Unknown key "title"
typeddicts_usage.py:40:24: error[invalid-type-form] The special form `typing.TypedDict` is not allowed in type expressions
-Found 1041 diagnostics
+Found 1042 diagnostics
|
Member
Author
|
The new typing-conformance diagnostic is a true positive. |
invalid-namedtuple on namedtuple classes that have field names starting with leading underscroresinvalid-namedtuple on namedtuple classes that have field names starting with leading underscores
invalid-namedtuple on namedtuple classes that have field names starting with leading underscoresinvalid-namedtuple on namedtuple classes that have field names starting with underscores
invalid-namedtuple on namedtuple classes that have field names starting with underscoresinvalid-named-tuple on namedtuple classes that have field names starting with underscores
|
Member
Author
|
The changes reported by mypy_primer are all unrelated (astral-sh/ty#1670) |
charliermarsh
approved these changes
Nov 30, 2025
…ting with leading underscrores
3972bd2 to
71ab5fc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This raises
TypeErrorat runtime and is caught by all other major type checkersTest Plan
snapshot/mdtest