| 
 | 1 | +---  | 
 | 2 | +source: crates/ty_test/src/lib.rs  | 
 | 3 | +expression: snapshot  | 
 | 4 | +---  | 
 | 5 | +---  | 
 | 6 | +mdtest name: function.md - Call expression - Wrong argument type - Diagnostics for union types where the union is not assignable  | 
 | 7 | +mdtest path: crates/ty_python_semantic/resources/mdtest/call/function.md  | 
 | 8 | +---  | 
 | 9 | + | 
 | 10 | +# Python source files  | 
 | 11 | + | 
 | 12 | +## mdtest_snippet.py  | 
 | 13 | + | 
 | 14 | +```  | 
 | 15 | + 1 | from typing import Sized  | 
 | 16 | + 2 |   | 
 | 17 | + 3 | class Foo: ...  | 
 | 18 | + 4 | class Bar: ...  | 
 | 19 | + 5 | class Baz: ...  | 
 | 20 | + 6 |   | 
 | 21 | + 7 | def f(x: Sized): ...  | 
 | 22 | + 8 | def g(  | 
 | 23 | + 9 |     a: str | Foo,  | 
 | 24 | +10 |     b: list[str] | str | dict[str, str] | tuple[str, ...] | bytes | frozenset[str] | set[str] | Foo,  | 
 | 25 | +11 |     c: list[str] | str | dict[str, str] | tuple[str, ...] | bytes | frozenset[str] | set[str] | Foo | Bar,  | 
 | 26 | +12 |     d: list[str] | str | dict[str, str] | tuple[str, ...] | bytes | frozenset[str] | set[str] | Foo | Bar | Baz,  | 
 | 27 | +13 | ):  | 
 | 28 | +14 |     f(a)  # error: [invalid-argument-type]  | 
 | 29 | +15 |     f(b)  # error: [invalid-argument-type]  | 
 | 30 | +16 |     f(c)  # error: [invalid-argument-type]  | 
 | 31 | +17 |     f(d)  # error: [invalid-argument-type]  | 
 | 32 | +```  | 
 | 33 | + | 
 | 34 | +# Diagnostics  | 
 | 35 | + | 
 | 36 | +```  | 
 | 37 | +error[invalid-argument-type]: Argument to function `f` is incorrect  | 
 | 38 | +  --> src/mdtest_snippet.py:14:7  | 
 | 39 | +   |  | 
 | 40 | +12 |     d: list[str] | str | dict[str, str] | tuple[str, ...] | bytes | frozenset[str] | set[str] | Foo | Bar | Baz,  | 
 | 41 | +13 | ):  | 
 | 42 | +14 |     f(a)  # error: [invalid-argument-type]  | 
 | 43 | +   |       ^ Expected `Sized`, found `str | Foo`  | 
 | 44 | +15 |     f(b)  # error: [invalid-argument-type]  | 
 | 45 | +16 |     f(c)  # error: [invalid-argument-type]  | 
 | 46 | +   |  | 
 | 47 | +info: Element `Foo` of this union is not assignable to `Sized`  | 
 | 48 | +info: Function defined here  | 
 | 49 | + --> src/mdtest_snippet.py:7:5  | 
 | 50 | +  |  | 
 | 51 | +5 | class Baz: ...  | 
 | 52 | +6 |  | 
 | 53 | +7 | def f(x: Sized): ...  | 
 | 54 | +  |     ^ -------- Parameter declared here  | 
 | 55 | +8 | def g(  | 
 | 56 | +9 |     a: str | Foo,  | 
 | 57 | +  |  | 
 | 58 | +info: rule `invalid-argument-type` is enabled by default  | 
 | 59 | + | 
 | 60 | +```  | 
 | 61 | + | 
 | 62 | +```  | 
 | 63 | +error[invalid-argument-type]: Argument to function `f` is incorrect  | 
 | 64 | +  --> src/mdtest_snippet.py:15:7  | 
 | 65 | +   |  | 
 | 66 | +13 | ):  | 
 | 67 | +14 |     f(a)  # error: [invalid-argument-type]  | 
 | 68 | +15 |     f(b)  # error: [invalid-argument-type]  | 
 | 69 | +   |       ^ Expected `Sized`, found `list[str] | str | dict[str, str] | ... omitted 5 union elements`  | 
 | 70 | +16 |     f(c)  # error: [invalid-argument-type]  | 
 | 71 | +17 |     f(d)  # error: [invalid-argument-type]  | 
 | 72 | +   |  | 
 | 73 | +info: Element `Foo` of this union is not assignable to `Sized`  | 
 | 74 | +info: Function defined here  | 
 | 75 | + --> src/mdtest_snippet.py:7:5  | 
 | 76 | +  |  | 
 | 77 | +5 | class Baz: ...  | 
 | 78 | +6 |  | 
 | 79 | +7 | def f(x: Sized): ...  | 
 | 80 | +  |     ^ -------- Parameter declared here  | 
 | 81 | +8 | def g(  | 
 | 82 | +9 |     a: str | Foo,  | 
 | 83 | +  |  | 
 | 84 | +info: rule `invalid-argument-type` is enabled by default  | 
 | 85 | + | 
 | 86 | +```  | 
 | 87 | + | 
 | 88 | +```  | 
 | 89 | +error[invalid-argument-type]: Argument to function `f` is incorrect  | 
 | 90 | +  --> src/mdtest_snippet.py:16:7  | 
 | 91 | +   |  | 
 | 92 | +14 |     f(a)  # error: [invalid-argument-type]  | 
 | 93 | +15 |     f(b)  # error: [invalid-argument-type]  | 
 | 94 | +16 |     f(c)  # error: [invalid-argument-type]  | 
 | 95 | +   |       ^ Expected `Sized`, found `list[str] | str | dict[str, str] | ... omitted 6 union elements`  | 
 | 96 | +17 |     f(d)  # error: [invalid-argument-type]  | 
 | 97 | +   |  | 
 | 98 | +info: Union elements `Foo` and `Bar` are not assignable to `Sized`  | 
 | 99 | +info: Function defined here  | 
 | 100 | + --> src/mdtest_snippet.py:7:5  | 
 | 101 | +  |  | 
 | 102 | +5 | class Baz: ...  | 
 | 103 | +6 |  | 
 | 104 | +7 | def f(x: Sized): ...  | 
 | 105 | +  |     ^ -------- Parameter declared here  | 
 | 106 | +8 | def g(  | 
 | 107 | +9 |     a: str | Foo,  | 
 | 108 | +  |  | 
 | 109 | +info: rule `invalid-argument-type` is enabled by default  | 
 | 110 | + | 
 | 111 | +```  | 
 | 112 | + | 
 | 113 | +```  | 
 | 114 | +error[invalid-argument-type]: Argument to function `f` is incorrect  | 
 | 115 | +  --> src/mdtest_snippet.py:17:7  | 
 | 116 | +   |  | 
 | 117 | +15 |     f(b)  # error: [invalid-argument-type]  | 
 | 118 | +16 |     f(c)  # error: [invalid-argument-type]  | 
 | 119 | +17 |     f(d)  # error: [invalid-argument-type]  | 
 | 120 | +   |       ^ Expected `Sized`, found `list[str] | str | dict[str, str] | ... omitted 7 union elements`  | 
 | 121 | +   |  | 
 | 122 | +info: Union element `Foo`, and 2 more union elements, are not assignable to `Sized`  | 
 | 123 | +info: Function defined here  | 
 | 124 | + --> src/mdtest_snippet.py:7:5  | 
 | 125 | +  |  | 
 | 126 | +5 | class Baz: ...  | 
 | 127 | +6 |  | 
 | 128 | +7 | def f(x: Sized): ...  | 
 | 129 | +  |     ^ -------- Parameter declared here  | 
 | 130 | +8 | def g(  | 
 | 131 | +9 |     a: str | Foo,  | 
 | 132 | +  |  | 
 | 133 | +info: rule `invalid-argument-type` is enabled by default  | 
 | 134 | + | 
 | 135 | +```  | 
0 commit comments