Skip to content

Commit e4e6dc5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d6824ee commit e4e6dc5

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

mypy/checkexpr.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -549,8 +549,8 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
549549
and e.callee.fullname == "typing.get_args"
550550
and len(e.args) == 1
551551
):
552-
#Special hanlding for get_args(), returns a typed tuple
553-
#with the type set by the input
552+
# Special hanlding for get_args(), returns a typed tuple
553+
# with the type set by the input
554554
typ = None
555555
if isinstance(e.args[0], IndexExpr):
556556
self.accept(e.args[0].index)
@@ -559,24 +559,29 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
559559
try:
560560
node = self.chk.lookup_qualified(e.args[0].name)
561561
except KeyError:
562-
# Undefined names should already be reported in semantic analysis.
563-
pass
562+
# Undefined names should already be reported in semantic analysis.
563+
pass
564564
if node:
565565
if isinstance(node.node, TypeAlias):
566-
#Resolve type
566+
# Resolve type
567567
typ = get_proper_type(node.node.target)
568568
else:
569569
typ = node.node.type
570-
if ( typ is not None
570+
if (
571+
typ is not None
571572
and isinstance(typ, UnionType)
572573
and all([isinstance(t, LiteralType) for t in typ.items])
573574
):
574575
# Returning strings is defined but order isn't so
575576
# we need to return type * len of the union
576-
return TupleType([typ] * len(typ.items), fallback=self.named_type("builtins.tuple"))
577+
return TupleType(
578+
[typ] * len(typ.items), fallback=self.named_type("builtins.tuple")
579+
)
577580
else:
578581
# Fall back to what we did anyway (Tuple[Any])
579-
return TupleType([AnyType(TypeOfAny.special_form)], fallback=self.named_type("builtins.tuple"))
582+
return TupleType(
583+
[AnyType(TypeOfAny.special_form)], fallback=self.named_type("builtins.tuple")
584+
)
580585
self.try_infer_partial_type(e)
581586
type_context = None
582587
if isinstance(e.callee, LambdaExpr):

test-data/unit/check-get-args.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ def external_function(input: str) -> Optional[str]:
7272
def _internal_function(input: ExpectedUserInput) -> str:
7373
return "User input: {input}"
7474
[builtins fixtures/primitives.pyi]
75-
[typing fixtures/typing-full.pyi]
75+
[typing fixtures/typing-full.pyi]

0 commit comments

Comments
 (0)