Skip to content

Commit b656ae3

Browse files
committed
lint
1 parent e8277e1 commit b656ae3

File tree

2 files changed

+66
-15
lines changed

2 files changed

+66
-15
lines changed

mypy/stubdoc.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,9 @@ def format_sig(
142142
args.append(arg_def)
143143

144144
if self.pos_only_index:
145-
args.insert(self.pos_only_index, '/')
145+
args.insert(self.pos_only_index, "/")
146146
if self.kwarg_only_index:
147-
args.insert(self.kwarg_only_index, '*')
147+
args.insert(self.kwarg_only_index, "*")
148148

149149
retfield = ""
150150
ret_type = self.ret_type if self.ret_type else any_val
@@ -273,7 +273,9 @@ def add_token(self, token: tokenize.TokenInfo) -> None:
273273
self.reset()
274274
return
275275
self.keyword_only = len(self.args)
276-
self.keyword_only_index = self.keyword_only + 1 if self.pos_only is not None else 0
276+
self.keyword_only_index = (
277+
self.keyword_only + 1 if self.pos_only is not None else 0
278+
)
277279
self.accumulator = ""
278280
else:
279281
if self.accumulator.startswith("*"):
@@ -351,7 +353,13 @@ def add_token(self, token: tokenize.TokenInfo) -> None:
351353

352354
if self.found:
353355
self.signatures.append(
354-
FunctionSig(name=self.function_name, args=self.args, pos_only_index=self.pos_only, kwarg_only_index=self.keyword_only_index, ret_type=self.ret_type)
356+
FunctionSig(
357+
name=self.function_name,
358+
args=self.args,
359+
pos_only_index=self.pos_only,
360+
kwarg_only_index=self.keyword_only_index,
361+
ret_type=self.ret_type,
362+
)
355363
)
356364
self.found = False
357365
self.args = []

mypy/test/teststubgen.py

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -437,28 +437,45 @@ def test_infer_sig_from_docstring_args_kwargs_errors(self) -> None:
437437
def test_infer_sig_from_docstring_positional_only_arguments(self) -> None:
438438
assert_equal(
439439
infer_sig_from_docstring("func(self, /) -> str", "func"),
440-
[FunctionSig(name="func", args=[ArgSig(name="self")], ret_type="str", pos_only_index=1)],
440+
[
441+
FunctionSig(
442+
name="func", args=[ArgSig(name="self")], ret_type="str", pos_only_index=1
443+
)
444+
],
441445
)
442446

443447
assert_equal(
444448
infer_sig_from_docstring("func(self, x, /) -> str", "func"),
445449
[
446450
FunctionSig(
447-
name="func", args=[ArgSig(name="self"), ArgSig(name="x")], ret_type="str", pos_only_index=2
451+
name="func",
452+
args=[ArgSig(name="self"), ArgSig(name="x")],
453+
ret_type="str",
454+
pos_only_index=2,
448455
)
449456
],
450457
)
451458

452459
assert_equal(
453460
infer_sig_from_docstring("func(x, /, y) -> int", "func"),
454-
[FunctionSig(name="func", args=[ArgSig(name="x"), ArgSig(name="y")], ret_type="int", pos_only_index=1)],
461+
[
462+
FunctionSig(
463+
name="func",
464+
args=[ArgSig(name="x"), ArgSig(name="y")],
465+
ret_type="int",
466+
pos_only_index=1,
467+
)
468+
],
455469
)
456470

457471
assert_equal(
458472
infer_sig_from_docstring("func(x, /, *args) -> str", "func"),
459473
[
460474
FunctionSig(
461-
name="func", args=[ArgSig(name="x"), ArgSig(name="*args")], ret_type="str", pos_only_index=1
475+
name="func",
476+
args=[ArgSig(name="x"), ArgSig(name="*args")],
477+
ret_type="str",
478+
pos_only_index=1,
462479
)
463480
],
464481
)
@@ -471,25 +488,43 @@ def test_infer_sig_from_docstring_positional_only_arguments(self) -> None:
471488
args=[ArgSig(name="x"), ArgSig(name="kwonly"), ArgSig(name="**kwargs")],
472489
ret_type="str",
473490
pos_only_index=1,
474-
kwarg_only_index=2
491+
kwarg_only_index=2,
475492
)
476493
],
477494
)
478495

479496
def test_infer_sig_from_docstring_keyword_only_arguments(self) -> None:
480497
assert_equal(
481498
infer_sig_from_docstring("func(*, x) -> str", "func"),
482-
[FunctionSig(name="func", args=[ArgSig(name="x")], ret_type="str", kwarg_only_index=0)],
499+
[
500+
FunctionSig(
501+
name="func", args=[ArgSig(name="x")], ret_type="str", kwarg_only_index=0
502+
)
503+
],
483504
)
484505

485506
assert_equal(
486507
infer_sig_from_docstring("func(x, *, y) -> str", "func"),
487-
[FunctionSig(name="func", args=[ArgSig(name="x"), ArgSig(name="y")], ret_type="str", kwarg_only_index=1)],
508+
[
509+
FunctionSig(
510+
name="func",
511+
args=[ArgSig(name="x"), ArgSig(name="y")],
512+
ret_type="str",
513+
kwarg_only_index=1,
514+
)
515+
],
488516
)
489517

490518
assert_equal(
491519
infer_sig_from_docstring("func(*, x, y) -> str", "func"),
492-
[FunctionSig(name="func", args=[ArgSig(name="x"), ArgSig(name="y")], ret_type="str", kwarg_only_index=0)],
520+
[
521+
FunctionSig(
522+
name="func",
523+
args=[ArgSig(name="x"), ArgSig(name="y")],
524+
ret_type="str",
525+
kwarg_only_index=0,
526+
)
527+
],
493528
)
494529

495530
assert_equal(
@@ -507,7 +542,15 @@ def test_infer_sig_from_docstring_keyword_only_arguments(self) -> None:
507542
def test_infer_sig_from_docstring_pos_only_and_keyword_only_arguments(self) -> None:
508543
assert_equal(
509544
infer_sig_from_docstring("func(x, /, *, y) -> str", "func"),
510-
[FunctionSig(name="func", args=[ArgSig(name="x"), ArgSig(name="y")], ret_type="str", pos_only_index=1, kwarg_only_index=2)],
545+
[
546+
FunctionSig(
547+
name="func",
548+
args=[ArgSig(name="x"), ArgSig(name="y")],
549+
ret_type="str",
550+
pos_only_index=1,
551+
kwarg_only_index=2,
552+
)
553+
],
511554
)
512555

513556
assert_equal(
@@ -518,7 +561,7 @@ def test_infer_sig_from_docstring_pos_only_and_keyword_only_arguments(self) -> N
518561
args=[ArgSig(name="x"), ArgSig(name="y"), ArgSig(name="z")],
519562
ret_type="str",
520563
pos_only_index=1,
521-
kwarg_only_index=3
564+
kwarg_only_index=3,
522565
)
523566
],
524567
)
@@ -536,7 +579,7 @@ def test_infer_sig_from_docstring_pos_only_and_keyword_only_arguments(self) -> N
536579
],
537580
ret_type="str",
538581
pos_only_index=1,
539-
kwarg_only_index=3
582+
kwarg_only_index=3,
540583
)
541584
],
542585
)

0 commit comments

Comments
 (0)