-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] infer name and value for enum members
#20311
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
Conversation
4606136 to
64c8a66
Compare
Diagnostic diff on typing conformance testsChanges were detected when running ty on typing conformance tests--- old-output.txt 2025-09-17 07:23:56.516264569 +0000
+++ new-output.txt 2025-09-17 07:23:59.584286258 +0000
@@ -316,16 +316,9 @@
enums_behaviors.py:32:1: error[type-assertion-failure] Argument does not have asserted type `Literal[Color.BLUE]`
enums_behaviors.py:44:21: error[subclass-of-final-class] Class `ExtendedShape` cannot inherit from final class `Shape`
enums_expansion.py:52:9: error[type-assertion-failure] Argument does not have asserted type `CustomFlags`
-enums_member_names.py:21:1: error[type-assertion-failure] Argument does not have asserted type `Literal["RED"]`
-enums_member_names.py:22:1: error[type-assertion-failure] Argument does not have asserted type `Literal["RED"]`
-enums_member_names.py:26:5: error[type-assertion-failure] Argument does not have asserted type `Literal["RED", "BLUE"]`
enums_member_names.py:30:5: error[type-assertion-failure] Argument does not have asserted type `Literal["RED", "BLUE", "GREEN"]`
-enums_member_values.py:21:1: error[type-assertion-failure] Argument does not have asserted type `Literal[1]`
-enums_member_values.py:22:1: error[type-assertion-failure] Argument does not have asserted type `Literal[1]`
-enums_member_values.py:26:5: error[type-assertion-failure] Argument does not have asserted type `Literal[1, 3]`
enums_member_values.py:30:5: error[type-assertion-failure] Argument does not have asserted type `Literal[1, 2, 3]`
enums_member_values.py:54:1: error[type-assertion-failure] Argument does not have asserted type `Literal[1]`
-enums_member_values.py:68:1: error[type-assertion-failure] Argument does not have asserted type `Literal[1]`
enums_member_values.py:96:1: error[type-assertion-failure] Argument does not have asserted type `int`
enums_members.py:128:21: info[revealed-type] Revealed type: `Unknown | Literal[2]`
enums_members.py:129:9: error[type-assertion-failure] Argument does not have asserted type `Unknown`
@@ -869,5 +862,5 @@
typeddicts_usage.py:28:1: error[missing-typed-dict-key] Missing required key 'name' in TypedDict `Movie` constructor
typeddicts_usage.py:28:18: error[invalid-key] Invalid key access on 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. Did you mean to use a concrete TypedDict or `collections.abc.Mapping[str, object]` instead?
-Found 870 diagnostics
+Found 863 diagnostics
WARN A fatal error occurred while checking some files. Not all project files were analyzed. See the diagnostics list above for details. |
|
|
@sharkdp could use some feedback on approach for i am thinking to add a anything im missing there or other recommendations? |
I would rather expect that we add the value
Yes, it looks like that would require adding a lifetime parameter to
I don't think so |
64c8a66 to
da7ed1f
Compare
CodSpeed Instrumentation Performance ReportMerging #20311 will not alter performanceComparing Summary
|
5c75f79 to
1c247f9
Compare
64830e6 to
809a225
Compare
|
name and value for enum members
c34449e to
a3af30d
Compare
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
type-assertion-failure |
1 | 11 | 0 |
invalid-argument-type |
0 | 0 | 2 |
| Total | 1 | 11 | 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. This looks great.
0370e59 to
0df220f
Compare
0df220f to
63fd2f4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Glad we could get rid of the performance regression.
summary
Enummembers:name_name_value_value_my_enum_class_instance.nameEnumre: this comment and existing testpointers
test plan
.value