|
| 1 | +[case testColumnsSyntaxError] |
| 2 | +# flags: --show-column-numbers |
| 3 | +1 + |
| 4 | +[out] |
| 5 | +main:2:3: error: Parse error before end of line |
| 6 | + |
| 7 | + |
| 8 | +[case testColumnsNestedFunctions] |
| 9 | +# flags: --show-column-numbers |
| 10 | +import typing |
| 11 | +def f() -> 'A': |
| 12 | + def g() -> 'B': |
| 13 | + return A() # fail |
| 14 | + return B() # fail |
| 15 | +class A: pass |
| 16 | +class B: pass |
| 17 | +[out] |
| 18 | +main: note: In function "g": |
| 19 | +main:5:8: error: Incompatible return value type (got "A", expected "B") |
| 20 | +main: note: In function "f": |
| 21 | +main:6:4: error: Incompatible return value type (got "B", expected "A") |
| 22 | + |
| 23 | +[case testColumnsNestedFunctionsWithFastParse] |
| 24 | +# flags: --show-column-numbers --fast-parser |
| 25 | +import typing |
| 26 | +def f() -> 'A': |
| 27 | + def g() -> 'B': |
| 28 | + return A() # fail |
| 29 | + return B() # fail |
| 30 | +class A: pass |
| 31 | +class B: pass |
| 32 | +[out] |
| 33 | +main: note: In function "g": |
| 34 | +main:5:8: error: Incompatible return value type (got "A", expected "B") |
| 35 | +main: note: In function "f": |
| 36 | +main:6:4: error: Incompatible return value type (got "B", expected "A") |
| 37 | + |
| 38 | + |
| 39 | +[case testColumnsMethodDefaultArgumentsAndSignatureAsComment] |
| 40 | +# flags: --show-column-numbers |
| 41 | +import typing |
| 42 | +class A: |
| 43 | + def f(self, x = 1, y = 'hello'): # type: (int, str) -> str |
| 44 | + pass |
| 45 | +A().f() |
| 46 | +A().f(1) |
| 47 | +A().f('') # E:5: Argument 1 to "f" of "A" has incompatible type "str"; expected "int" |
| 48 | +A().f(1, 1) # E:5: Argument 2 to "f" of "A" has incompatible type "int"; expected "str" |
| 49 | +A().f(1, 'hello', 'hi') # E:5: Too many arguments for "f" of "A" |
| 50 | + |
| 51 | +[case testColumnsMultipleStatementsPerLine] |
| 52 | +# flags: --show-column-numbers |
| 53 | +x = 1 |
| 54 | +y = 'hello' |
| 55 | +x = 2; y = x; y += 1 |
| 56 | +[out] |
| 57 | +main:4:7: error: Incompatible types in assignment (expression has type "int", variable has type "str") |
| 58 | +main:4:14: error: Unsupported operand types for + ("str" and "int") |
| 59 | + |
| 60 | +[case testColumnsSimpleIsinstance] |
| 61 | +# flags: --show-column-numbers |
| 62 | +import typing |
| 63 | +def f(x: object, n: int, s: str) -> None: |
| 64 | + n = x # E:4: Incompatible types in assignment (expression has type "object", variable has type "int") |
| 65 | + if isinstance(x, int): |
| 66 | + n = x |
| 67 | + s = x # E:8: Incompatible types in assignment (expression has type "int", variable has type "str") |
| 68 | + n = x # E:4: Incompatible types in assignment (expression has type "object", variable has type "int") |
| 69 | +[builtins fixtures/isinstance.pyi] |
| 70 | +[out] |
| 71 | +main: note: In function "f": |
| 72 | + |
| 73 | + |
0 commit comments