Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
.
  • Loading branch information
hauntsaninja committed Jul 20, 2024
commit 90132728c71f8e95928e52180579aae643d3d094
20 changes: 17 additions & 3 deletions test-data/unit/check-functions.test
Original file line number Diff line number Diff line change
Expand Up @@ -1779,6 +1779,7 @@ def Arg(x, y): pass
F = Callable[[Arg(int, 'x')], int] # E: Invalid argument constructor "__main__.Arg"

[case testCallableParsingFromExpr]
# flags: --python-version 3.9
from typing import Callable, List
from mypy_extensions import Arg, VarArg, KwArg
import mypy_extensions
Expand All @@ -1799,10 +1800,23 @@ L = Callable[[Arg(name='x', type=int)], int] # ok
# I have commented out the following test because I don't know how to expect the "defined here" note part of the error.
# M = Callable[[Arg(gnome='x', type=int)], int] E: Invalid type alias: expression is not a valid type E: Unexpected keyword argument "gnome" for "Arg"
N = Callable[[Arg(name=None, type=int)], int] # ok
O = Callable[[List[Arg(int)]], int] # E: Invalid type alias: expression is not a valid type # E: Value of type "int" is not indexable # E: Type expected within [...]
O = Callable[[List[Arg(int)]], int] # E: Invalid type alias: expression is not a valid type \
# E: Value of type "int" is not indexable \
# E: Type expected within [...]
P = Callable[[mypy_extensions.VarArg(int)], int] # ok
Q = Callable[[Arg(int, type=int)], int] # E: Invalid type alias: expression is not a valid type # E: Value of type "int" is not indexable # E: "Arg" gets multiple values for keyword argument "type"
R = Callable[[Arg(int, 'x', name='y')], int] # E: Invalid type alias: expression is not a valid type # E: Value of type "int" is not indexable # E: "Arg" gets multiple values for keyword argument "name"
Q = Callable[[Arg(int, type=int)], int] # E: Invalid type alias: expression is not a valid type \
# E: Value of type "int" is not indexable \
# E: "Arg" gets multiple values for keyword argument "type"
R = Callable[[Arg(int, 'x', name='y')], int] # E: Invalid type alias: expression is not a valid type \
# E: Value of type "int" is not indexable \
# E: "Arg" gets multiple values for keyword argument "name"







[builtins fixtures/dict.pyi]

[case testCallableParsing]
Expand Down