KEMBAR78
Use more precise context for invalid type argument errors by brianschubert · Pull Request #18290 · python/mypy · GitHub
Skip to content

Conversation

brianschubert
Copy link
Member

Fixes #12274

Uses the actual invalid type argument as the error context when possible.

Given:

# flags: --pretty --show-column-number
class Foo[S, T: int]: 
    pass

x: Foo[str, str]

Before:

main.py:3:4: error: Type argument "str" of "Foo" must be a subtype of "int"  [type-var]
    x: Foo[str, str]
       ^

After:

main.py:3:13: error: Type argument "str" of "Foo" must be a subtype of "int"  [type-var]
    x: Foo[str, str]
                ^

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

AutoSplit (https://github.com/Toufool/AutoSplit)
- typings/cv2/mat_wrapper/__init__.pyi:7:23: error: Type argument "float" of "ndarray" must be a subtype of "tuple[int, ...]"  [type-var]
+ typings/cv2/mat_wrapper/__init__.pyi:7:34: error: Type argument "float" of "ndarray" must be a subtype of "tuple[int, ...]"  [type-var]

@hauntsaninja hauntsaninja merged commit 9db2368 into python:master Dec 14, 2024
19 checks passed
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

Successfully merging this pull request may close these issues.

(🐞) Wrong column number for "Invalid location for ParamSpec"

2 participants