Skip to content
Merged
Changes from 1 commit
Commits
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
16 changes: 13 additions & 3 deletions test-data/unit/check-typeguard.test
Original file line number Diff line number Diff line change
Expand Up @@ -602,21 +602,31 @@ def func(names: Tuple[str, ...]):
from typing_extensions import TypeGuard

class Z:
def typeguard1(self, *, x: object) -> TypeGuard[int]: # E: TypeGuard functions must have a positional argument
def typeguard1(self, *, x: object) -> TypeGuard[int]: # line 4
...

@staticmethod
def typeguard2(x: object) -> TypeGuard[int]:
...

@staticmethod # E: TypeGuard functions must have a positional argument
@staticmethod # line 11
def typeguard3(*, x: object) -> TypeGuard[int]:
...

def bad_typeguard(*, x: object) -> TypeGuard[int]: # E: TypeGuard functions must have a positional argument
def bad_typeguard(*, x: object) -> TypeGuard[int]: # line 15
...

# seperated outputs are due to a parsing difference (?)
Comment thread
A5rocks marked this conversation as resolved.
Outdated
Comment thread
hauntsaninja marked this conversation as resolved.
Outdated
[builtins fixtures/tuple.pyi]
[builtins fixtures/classmethod.pyi]
Comment thread
A5rocks marked this conversation as resolved.
[out]
main:4: error: TypeGuard functions must have a positional argument
main:11: error: TypeGuard functions must have a positional argument
main:15: error: TypeGuard functions must have a positional argument
[out version>=3.8]
main:4: error: TypeGuard functions must have a positional argument
main:12: error: TypeGuard functions must have a positional argument
main:15: error: TypeGuard functions must have a positional argument

[case testTypeGuardWithKeywordArg]
from typing_extensions import TypeGuard
Expand Down