Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8a30073
Basic work on TypeNarrower
JelleZijlstra Feb 9, 2024
58e8403
Initial tests (many failing)
JelleZijlstra Feb 9, 2024
c8d2af8
Fewer test failures
JelleZijlstra Feb 10, 2024
f205910
Fix the remaining tests
JelleZijlstra Feb 10, 2024
75c9dec
Did not actually need TypeNarrowerType
JelleZijlstra Feb 10, 2024
4666486
Error for bad narrowing
JelleZijlstra Feb 10, 2024
25a9c79
temp change typeshed
JelleZijlstra Feb 10, 2024
faa4a07
Fixes
JelleZijlstra Feb 10, 2024
c0e0210
Merge branch 'master' into typenarrower
JelleZijlstra Feb 10, 2024
f107e5b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 10, 2024
34700bb
doc
JelleZijlstra Feb 10, 2024
065ec92
fix self check
JelleZijlstra Feb 10, 2024
aef3036
like this maybe
JelleZijlstra Feb 10, 2024
4b19c77
Merge remote-tracking branch 'upstream/master' into typenarrower
JelleZijlstra Feb 10, 2024
6b0e749
Fix and add tests
JelleZijlstra Feb 10, 2024
c9e53e6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 10, 2024
909e53c
Use TypeIs
JelleZijlstra Feb 14, 2024
eb88371
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 14, 2024
1b1e368
Apply suggestions from code review
JelleZijlstra Feb 22, 2024
84c69d2
Code review feedback, new test case, fix incorrect constraints
JelleZijlstra Feb 23, 2024
ae294bf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 23, 2024
7fedbcf
Merge remote-tracking branch 'upstream/master' into typenarrower
JelleZijlstra Mar 1, 2024
dbc229d
Rename error code
JelleZijlstra Mar 1, 2024
8b2fb0b
Quote name
JelleZijlstra Mar 1, 2024
816fd1a
unxfail
JelleZijlstra Mar 1, 2024
d6fcc35
add elif test
JelleZijlstra Mar 1, 2024
ef825ce
type context test
JelleZijlstra Mar 1, 2024
d32956d
Add test
JelleZijlstra Mar 1, 2024
a36a16a
Add error code test case
JelleZijlstra Mar 1, 2024
b32ba80
update docs
JelleZijlstra Mar 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Quote name
  • Loading branch information
JelleZijlstra committed Mar 1, 2024
commit 8b2fb0b9bcf75247377a8a2870e7d2ce9f994ddd
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ def analyze_func_def(self, defn: FuncDef) -> None:
result = result.copy_modified(type_guard=None)
if result.type_is and ARG_POS not in result.arg_kinds[skip_self:]:
self.fail(
"TypeIs functions must have a positional argument",
'"TypeIs" functions must have a positional argument',
result,
code=codes.VALID_TYPE,
)
Expand Down
8 changes: 4 additions & 4 deletions test-data/unit/check-typeis.test
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ reveal_type(foo) # N: Revealed type is "def (a: builtins.object) -> TypeIs[buil
from typing_extensions import TypeIs
class Point: pass

def is_point() -> TypeIs[Point]: pass # E: TypeIs functions must have a positional argument
def is_point() -> TypeIs[Point]: pass # E: "TypeIs" functions must have a positional argument
def main(a: object) -> None:
if is_point():
reveal_type(a) # N: Revealed type is "builtins.object"
Expand Down Expand Up @@ -585,18 +585,18 @@ def func(names: Tuple[str, ...]):
from typing_extensions import TypeIs

class Z:
def typeis1(self, *, x: object) -> TypeIs[int]: # E: TypeIs functions must have a positional argument
def typeis1(self, *, x: object) -> TypeIs[int]: # E: "TypeIs" functions must have a positional argument
...

@staticmethod
def typeis2(x: object) -> TypeIs[int]:
...

@staticmethod
def typeis3(*, x: object) -> TypeIs[int]: # E: TypeIs functions must have a positional argument
def typeis3(*, x: object) -> TypeIs[int]: # E: "TypeIs" functions must have a positional argument
...

def bad_typeis(*, x: object) -> TypeIs[int]: # E: TypeIs functions must have a positional argument
def bad_typeis(*, x: object) -> TypeIs[int]: # E: "TypeIs" functions must have a positional argument
...

[builtins fixtures/classmethod.pyi]
Expand Down