|
62 | 62 | from mypy.types import ( |
63 | 63 | ANNOTATED_TYPE_NAMES, |
64 | 64 | ANY_STRATEGY, |
| 65 | + CONCATENATE_TYPE_NAMES, |
65 | 66 | FINAL_TYPE_NAMES, |
66 | 67 | LITERAL_TYPE_NAMES, |
67 | 68 | NEVER_NAMES, |
68 | 69 | TYPE_ALIAS_NAMES, |
| 70 | + UNPACK_TYPE_NAMES, |
69 | 71 | AnyType, |
70 | 72 | BoolTypeQuery, |
71 | 73 | CallableArgument, |
@@ -525,7 +527,7 @@ def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool) |
525 | 527 | elif node.fullname in TYPE_ALIAS_NAMES: |
526 | 528 | return AnyType(TypeOfAny.special_form) |
527 | 529 | # Concatenate is an operator, no need for a proper type |
528 | | - elif node.fullname in ("typing_extensions.Concatenate", "typing.Concatenate"): |
| 530 | + elif node.fullname in CONCATENATE_TYPE_NAMES: |
529 | 531 | # We check the return type further up the stack for valid use locations |
530 | 532 | return self.apply_concatenate_operator(t) |
531 | 533 | else: |
@@ -779,7 +781,7 @@ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Typ |
779 | 781 | ): |
780 | 782 | # In most contexts, TypeGuard[...] acts as an alias for bool (ignoring its args) |
781 | 783 | return self.named_type("builtins.bool") |
782 | | - elif fullname in ("typing.Unpack", "typing_extensions.Unpack"): |
| 784 | + elif fullname in UNPACK_TYPE_NAMES: |
783 | 785 | if len(t.args) != 1: |
784 | 786 | self.fail("Unpack[...] requires exactly one type argument", t) |
785 | 787 | return AnyType(TypeOfAny.from_error) |
@@ -1503,7 +1505,7 @@ def analyze_callable_args_for_concatenate( |
1503 | 1505 | return None |
1504 | 1506 | if sym.node is None: |
1505 | 1507 | return None |
1506 | | - if sym.node.fullname not in ("typing_extensions.Concatenate", "typing.Concatenate"): |
| 1508 | + if sym.node.fullname not in CONCATENATE_TYPE_NAMES: |
1507 | 1509 | return None |
1508 | 1510 |
|
1509 | 1511 | tvar_def = self.anal_type(callable_args, allow_param_spec=True) |
@@ -1652,7 +1654,7 @@ def analyze_callable_args( |
1652 | 1654 | return None |
1653 | 1655 | elif ( |
1654 | 1656 | isinstance(arg, UnboundType) |
1655 | | - and self.refers_to_full_names(arg, ("typing_extensions.Unpack", "typing.Unpack")) |
| 1657 | + and self.refers_to_full_names(arg, UNPACK_TYPE_NAMES) |
1656 | 1658 | or isinstance(arg, UnpackType) |
1657 | 1659 | ): |
1658 | 1660 | if seen_unpack: |
|
0 commit comments