[ty] Model int and str enum value normalization#26349
Draft
charliermarsh wants to merge 15 commits into
Draft
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.47%. The percentage of expected errors that received a diagnostic held steady at 89.19%. The number of fully passing files held steady at 95/134. |
Memory usage reportMemory usage unchanged ✅ |
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
0 | 7 | 0 |
| Total | 0 | 7 | 0 |
Raw diff:
schemathesis (https://github.com/schemathesis/schemathesis)
- src/schemathesis/generation/overrides.py:75:59 error[invalid-argument-type] Argument to function `lookup_parameter` is incorrect: Expected `str`, found `Literal["query", "header", "path", "cookie", "body"] | None`
- src/schemathesis/generation/dictionaries.py:112:73 error[invalid-argument-type] Argument to function `_find_parameter_binding` is incorrect: Expected `str`, found `Literal["query", "header", "path", "cookie", "body"] | None`
- src/schemathesis/generation/dictionaries.py:115:97 error[invalid-argument-type] Argument to function `_find_parameter_binding` is incorrect: Expected `str`, found `Literal["query", "header", "path", "cookie", "body"] | None`
- src/schemathesis/generation/dictionaries.py:230:21 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal["query", "header", "path", "cookie", "body"] | None`
- src/schemathesis/specs/openapi/extra_data_source.py:181:9 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal["query", "header", "path", "cookie", "body"] | None`
- src/schemathesis/specs/openapi/extra_data_source.py:199:9 error[invalid-argument-type] Argument is incorrect: Expected `str`, found `Literal["query", "header", "path", "cookie", "body"] | None`
- src/schemathesis/specs/openapi/extra_data_source.py:645:38 error[invalid-argument-type] Argument to bound method `list.append` is incorrect: Expected `tuple[str, str]`, found `tuple[Literal["query", "header", "path", "cookie", "body"] | None, str]`
Merging this PR will degrade performance by 4.57%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression with the CodSpeed MCP and your agent. Comparing Footnotes
|
e443c06 to
99e6ef0
Compare
65f063a to
1599879
Compare
99e6ef0 to
70a659b
Compare
1599879 to
6ce7e33
Compare
70a659b to
579b61b
Compare
579b61b to
193d068
Compare
2f27190 to
532e2cd
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
Enum data types construct a member's
_value_before aliases are registered. Prior to this change, we used the declared right-hand side for both.valueinference and alias detection, so constructor normalization could be lost and runtime aliases could remain separate canonical members.This PR models the normalization performed when an enum's data type is the known built-in
intorstr:We apply the same model through
IntEnum,StrEnum, and memberless parent enum bases, recursively normalize union-valued members, and normalize generatedauto()values. Aliased declarations still contribute their raw right-hand sides to the history used by a following_generate_next_value_call.User-defined data types remain opaque for
.valueinference and alias detection, even when they inherit fromintorstrwithout overriding methods. This avoids assuming that arbitrary construction, attribute access, equality, or hashing behavior matches the built-in scalar.