Skip to content

Commit db0765f

Browse files
committed
Allow positional args to Any
1 parent 9c99c83 commit db0765f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mypy/checkpattern.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ def should_self_match(self, typ: Type) -> bool:
693693
typ = get_proper_type(typ)
694694
if isinstance(typ, TupleType):
695695
typ = typ.partial_fallback
696+
if isinstance(typ, AnyType):
697+
return False
696698
if isinstance(typ, Instance) and typ.type.get("__match_args__") is not None:
697699
# Named tuples and other subtypes of builtins that define __match_args__
698700
# should not self match.

test-data/unit/check-python310.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,3 +2998,11 @@ class A:
29982998
match 5:
29992999
case A.blah(): # E: "type[A]" has no attribute "blah"
30003000
pass
3001+
3002+
[case testMatchAllowsAnyClassArgsForAny]
3003+
match 5:
3004+
case BlahBlah(a, b): # E: Name "BlahBlah" is not defined
3005+
reveal_type(a) # N: Revealed type is "Any"
3006+
reveal_type(b) # N: Revealed type is "Any"
3007+
case BlahBlah(c=c): # E: Name "BlahBlah" is not defined
3008+
reveal_type(c) # N: Revealed type is "Any"

0 commit comments

Comments
 (0)