|
28 | 28 | main:14: note: Revealed type is "def (a: int, b: int, c: int =, *args: float, d: str, e: bool =, **kwargs: str) -> str" |
29 | 29 | main:15: note: Revealed type is "def (b: int, c: int =, *args: float, d: str, e: bool =, **kwargs: str) -> str" |
30 | 30 | main:16: note: Revealed type is "def (c: int =, *args: float, d: str, e: bool =, **kwargs: str) -> str" |
31 | | - main:17: note: Revealed type is "def (*args: float, d: str, e: bool =, **kwargs: str) -> str" |
32 | | - main:18: note: Revealed type is "def (*args: float, e: bool =, **kwargs: str) -> str" |
33 | | - main:19: note: Revealed type is "def (*args: float, d: str, **kwargs: str) -> str" |
| 31 | + main:17: note: Revealed type is "def (*, d: str, e: bool =, **kwargs: str) -> str" |
| 32 | + main:18: note: Revealed type is "def (*, e: bool =, **kwargs: str) -> str" |
| 33 | + main:19: note: Revealed type is "def (*, d: str, **kwargs: str) -> str" |
34 | 34 | main:20: note: Revealed type is "def (c: int =, *args: float, e: bool =, **kwargs: str) -> str" |
35 | 35 | main:21: note: Revealed type is "def (c: int =, *args: float, d: str, **kwargs: str) -> str" |
36 | 36 | main:22: note: Revealed type is "def (*args: float, d: str, e: bool =, **kwargs: str) -> str" |
|
211 | 211 | from returns.curry import partial |
212 | 212 |
|
213 | 213 | reveal_type(partial((lambda x, y: str(x + y)), 1)) # N: Revealed type is "def (y: Any) -> str" |
| 214 | +
|
| 215 | +
|
| 216 | +- case: partial_variadic_argument_binding |
| 217 | + disable_cache: false |
| 218 | + main: | |
| 219 | + from returns.curry import partial |
| 220 | +
|
| 221 | + def multiple(first: int, *args: int, flag: bool = False) -> str: |
| 222 | + ... |
| 223 | +
|
| 224 | + bound = partial(multiple, first=1) |
| 225 | + reveal_type(bound) # N: Revealed type is "def (*, flag: bool =) -> str" |
| 226 | + reveal_type(bound(flag=True)) # N: Revealed type is "str" |
| 227 | + bound(True) # E: Too many positional arguments [call-arg] |
| 228 | +
|
| 229 | + keyword_bound = partial(multiple, flag=True) |
| 230 | + reveal_type(keyword_bound) # N: Revealed type is "def (first: int, *args: int) -> str" |
| 231 | + reveal_type(keyword_bound(1, 2, 3)) # N: Revealed type is "str" |
| 232 | +
|
| 233 | + positional_bound = partial(multiple, 1, 2) |
| 234 | + reveal_type(positional_bound) # N: Revealed type is "def (*args: int, flag: bool =) -> str" |
| 235 | + reveal_type(positional_bound(3, 4, flag=True)) # N: Revealed type is "str" |
| 236 | +
|
| 237 | +
|
| 238 | +- case: partial_keyword_hole_before_varargs_keeps_prefix |
| 239 | + disable_cache: false |
| 240 | + main: | |
| 241 | + from returns.curry import partial |
| 242 | +
|
| 243 | + def multiple(first: int, second: int, *args: int, flag: bool = False) -> str: |
| 244 | + ... |
| 245 | +
|
| 246 | + bound = partial(multiple, second=2) |
| 247 | + reveal_type(bound) # N: Revealed type is "def (first: int, *, flag: bool =) -> str" |
| 248 | + bound(1, flag=True) |
| 249 | + bound(1, True) # E: Too many positional arguments [call-arg] |
0 commit comments