[WIP] Add Python version checks to native parser#21539
Conversation
This comment has been minimized.
This comment has been minimized.
fc2b267 to
3a8407e
Compare
for more information, see https://pre-commit.ci
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
JukkaL
left a comment
There was a problem hiding this comment.
Also these features may need checks:
- Star unpack (
tuple[*Ts]) introduced in 3.11 - Parentheses optional for multiple exception types in except
The latter may require changes to the parser. If that's the case, we can leave it until later.
| column, | ||
| blocker=False, | ||
| code="syntax", | ||
| ) |
There was a problem hiding this comment.
Also add a note like "Current target Python version is X.Y"?
| func_def.is_coroutine = True | ||
| read_loc(data, func_def) | ||
| if type_params: | ||
| state.check_min_version("Type parameter lists", (3, 12), func_def.line, func_def.column) |
There was a problem hiding this comment.
Maybe call this feature "Improved type parameter syntax"? You'd need to use singular "is" instead of "are" in the error message in this case, or leave out the verb altogether.
| class_def.decorators = decorators | ||
| read_loc(data, class_def) | ||
| if type_params: | ||
| state.check_min_version("Type parameter lists", (3, 12), class_def.line, class_def.column) |
There was a problem hiding this comment.
Similar to above (name of feature).
| titems.append(s) | ||
| expr = TemplateStrExpr(titems) | ||
| read_loc(data, expr) | ||
| state.check_min_version("t-strings", (3, 14), expr.line, expr.column) |
There was a problem hiding this comment.
I think T-strings are a bit special since they need to new stdlib type, and it's not defined on older versions. This means that we probably shouldn't allow them in stubs either unless targeting 3.14 or later. Also this is important to test using real stubs (pythoneval.test) to ensure the missing type doesn't cause issues.
No description provided.