|
150 | 150 | function: Callable[[_SecondType, _FirstType], _SecondType], |
151 | 151 | ): |
152 | 152 | reveal_type(partial(function, default)) # N: Revealed type is "def (_FirstType`-2) -> _SecondType`-1" |
| 153 | +
|
| 154 | +
|
| 155 | +- case: partial_regression1711 |
| 156 | + disable_cache: false |
| 157 | + main: | |
| 158 | + from returns.curry import partial |
| 159 | +
|
| 160 | + def foo(x: int, y: int, z: int) -> int: |
| 161 | + ... |
| 162 | +
|
| 163 | + def bar(x: int) -> int: |
| 164 | + ... |
| 165 | +
|
| 166 | + baz = partial(foo, bar(1)) |
| 167 | + reveal_type(baz) # N: Revealed type is "def (y: builtins.int, z: builtins.int) -> builtins.int" |
| 168 | +
|
| 169 | +
|
| 170 | +- case: partial_optional_arg |
| 171 | + disable_cache: false |
| 172 | + main: | |
| 173 | + from returns.curry import partial |
| 174 | +
|
| 175 | + def test_partial_fn( |
| 176 | + first_arg: int, |
| 177 | + optional_arg: str | None, |
| 178 | + ) -> tuple[int, str | None]: |
| 179 | + ... |
| 180 | +
|
| 181 | + bound = partial(test_partial_fn, 1) |
| 182 | + reveal_type(bound) # N: Revealed type is "def (optional_arg: builtins.str | None) -> tuple[builtins.int, builtins.str | None]" |
| 183 | +
|
| 184 | +
|
| 185 | +- case: partial_decorator |
| 186 | + disable_cache: false |
| 187 | + main: | |
| 188 | + from returns.curry import partial |
| 189 | +
|
| 190 | + @partial(first=1) |
| 191 | + def _decorated(first: int, second: str) -> float: |
| 192 | + ... |
| 193 | +
|
| 194 | + reveal_type(_decorated) # N: Revealed type is "Any" |
| 195 | + out: | |
| 196 | + main:3: error: Untyped decorator makes function "_decorated" untyped [misc] |
| 197 | +
|
| 198 | +
|
| 199 | +- case: partial_keyword_arg |
| 200 | + disable_cache: false |
| 201 | + main: | |
| 202 | + from returns.curry import partial |
| 203 | +
|
| 204 | + def test_partial_fn( |
| 205 | + first_arg: int, |
| 206 | + optional_arg: str | None, |
| 207 | + ) -> tuple[int, str | None]: |
| 208 | + ... |
| 209 | +
|
| 210 | + bound = partial(test_partial_fn, optional_arg='a') |
| 211 | + reveal_type(bound) # N: Revealed type is "def (first_arg: builtins.int) -> tuple[builtins.int, builtins.str | None]" |
| 212 | +
|
| 213 | +
|
| 214 | +- case: partial_keyword_only |
| 215 | + disable_cache: false |
| 216 | + main: | |
| 217 | + from returns.curry import partial |
| 218 | +
|
| 219 | + def _target(*, arg: int) -> int: |
| 220 | + ... |
| 221 | +
|
| 222 | + bound = partial(_target, arg=1) |
| 223 | + reveal_type(bound) # N: Revealed type is "def () -> builtins.int" |
| 224 | +
|
| 225 | +
|
| 226 | +- case: partial_keyword_mixed |
| 227 | + disable_cache: false |
| 228 | + main: | |
| 229 | + from returns.curry import partial |
| 230 | +
|
| 231 | + def _target(arg1: int, *, arg2: int) -> int: |
| 232 | + ... |
| 233 | +
|
| 234 | + bound = partial(_target, arg2=1) |
| 235 | + reveal_type(bound) # N: Revealed type is "def (arg1: builtins.int) -> builtins.int" |
| 236 | +
|
| 237 | +
|
| 238 | +- case: partial_wrong_signature_any |
| 239 | + disable_cache: false |
| 240 | + main: | |
| 241 | + from returns.curry import partial |
| 242 | +
|
| 243 | + reveal_type(partial(len, 1)) |
| 244 | + out: | |
| 245 | + main:3: error: Argument 1 to "len" has incompatible type "int"; expected "Sized" [arg-type] |
| 246 | + main:3: note: Revealed type is "def (*Any, **Any) -> builtins.int" |
0 commit comments