Skip to content

Commit 1fa74d3

Browse files
Merge branch 'master' into for-loop-len-cache
2 parents 69bd43d + 116b92b commit 1fa74d3

File tree

6 files changed

+316
-81
lines changed

6 files changed

+316
-81
lines changed

mypy/checkexpr.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,10 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
582582
and not node.node.no_args
583583
and not (
584584
isinstance(union_target := get_proper_type(node.node.target), UnionType)
585-
and union_target.uses_pep604_syntax
585+
and (
586+
union_target.uses_pep604_syntax
587+
or self.chk.options.python_version >= (3, 10)
588+
)
586589
)
587590
):
588591
self.msg.type_arguments_not_allowed(e)

mypy/checkpattern.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def visit_or_pattern(self, o: OrPattern) -> PatternType:
192192
for capture_list in capture_types.values():
193193
typ = UninhabitedType()
194194
for _, other in capture_list:
195-
typ = join_types(typ, other)
195+
typ = make_simplified_union([typ, other])
196196

197197
captures[capture_list[0][0]] = typ
198198

@@ -539,12 +539,12 @@ def visit_class_pattern(self, o: ClassPattern) -> PatternType:
539539
#
540540
type_info = o.class_ref.node
541541
if type_info is None:
542-
return PatternType(AnyType(TypeOfAny.from_error), AnyType(TypeOfAny.from_error), {})
543-
if isinstance(type_info, TypeAlias) and not type_info.no_args:
542+
typ: Type = AnyType(TypeOfAny.from_error)
543+
elif isinstance(type_info, TypeAlias) and not type_info.no_args:
544544
self.msg.fail(message_registry.CLASS_PATTERN_GENERIC_TYPE_ALIAS, o)
545545
return self.early_non_match()
546-
if isinstance(type_info, TypeInfo):
547-
typ: Type = fill_typevars_with_any(type_info)
546+
elif isinstance(type_info, TypeInfo):
547+
typ = fill_typevars_with_any(type_info)
548548
elif isinstance(type_info, TypeAlias):
549549
typ = type_info.target
550550
elif (

0 commit comments

Comments
 (0)