Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for functools.partial #16939

Merged
merged 14 commits into from
May 23, 2024
Prev Previous commit
Next Next commit
Merge branch 'master' into functools-partial
  • Loading branch information
hauntsaninja committed May 21, 2024
commit 0b460811bfb9a3a05ef6ed0f093d792524a297aa
77 changes: 77 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -6634,3 +6634,80 @@ tmp/partial.py:4: note: "foo" defined here
[out2]
tmp/a.py:8: error: Too many positional arguments for "foo"
tmp/a.py:8: error: Argument 2 to "foo" has incompatible type "int"; expected "str"


[case testStartUsingTypeGuard]
import a
[file a.py]
from lib import guard
from typing import Union
from typing_extensions import assert_type
x: Union[int, str]

[file a.py.2]
from lib import guard
from typing import Union
from typing_extensions import assert_type
x: Union[int, str]
if guard(x):
assert_type(x, int)
else:
assert_type(x, Union[int, str])
[file lib.py]
from typing_extensions import TypeGuard
def guard(x: object) -> TypeGuard[int]:
pass
[builtins fixtures/tuple.pyi]

[case testStartUsingTypeIs]
import a
[file a.py]
from lib import guard
from typing import Union
from typing_extensions import assert_type
x: Union[int, str]

[file a.py.2]
from lib import guard
from typing import Union
from typing_extensions import assert_type
x: Union[int, str]
if guard(x):
assert_type(x, int)
else:
assert_type(x, str)
[file lib.py]
from typing_extensions import TypeIs
def guard(x: object) -> TypeIs[int]:
pass
[builtins fixtures/tuple.pyi]

[case testTypeGuardToTypeIs]
import a
[file a.py]
from lib import guard
from typing import Union
from typing_extensions import assert_type
x: Union[int, str]
if guard(x):
assert_type(x, int)
else:
assert_type(x, Union[int, str])
[file a.py.2]
from lib import guard
from typing import Union
from typing_extensions import assert_type
x: Union[int, str]
if guard(x):
assert_type(x, int)
else:
assert_type(x, str)
[file lib.py]
from typing_extensions import TypeGuard
def guard(x: object) -> TypeGuard[int]:
pass
[file lib.py.2]
from typing_extensions import TypeIs
def guard(x: object) -> TypeIs[int]:
pass
[builtins fixtures/tuple.pyi]
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.