Skip to content

Commit 2e6d11e

Browse files
authored
Clarify difference between disallow_untyped_defs and disallow_incomplete_defs (#15247)
Fixes #9963, fixes #12693
1 parent 905c2cb commit 2e6d11e

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

docs/source/command_line.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,12 +353,17 @@ definitions or calls.
353353
.. option:: --disallow-untyped-defs
354354

355355
This flag reports an error whenever it encounters a function definition
356-
without type annotations.
356+
without type annotations or with incomplete type annotations.
357+
(a superset of :option:`--disallow-incomplete-defs`).
358+
359+
For example, it would report an error for :code:`def f(a, b)` and :code:`def f(a: int, b)`.
357360

358361
.. option:: --disallow-incomplete-defs
359362

360363
This flag reports an error whenever it encounters a partly annotated
361-
function definition.
364+
function definition, while still allowing entirely unannotated definitions.
365+
366+
For example, it would report an error for :code:`def f(a: int, b)` but not :code:`def f(a, b)`.
362367

363368
.. option:: --check-untyped-defs
364369

docs/source/config_file.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,14 +498,19 @@ section of the command line docs.
498498
:default: False
499499

500500
Disallows defining functions without type annotations or with incomplete type
501-
annotations.
501+
annotations (a superset of :confval:`disallow_incomplete_defs`).
502+
503+
For example, it would report an error for :code:`def f(a, b)` and :code:`def f(a: int, b)`.
502504

503505
.. confval:: disallow_incomplete_defs
504506

505507
:type: boolean
506508
:default: False
507509

508-
Disallows defining functions with incomplete type annotations.
510+
Disallows defining functions with incomplete type annotations, while still
511+
allowing entirely unannotated definitions.
512+
513+
For example, it would report an error for :code:`def f(a: int, b)` but not :code:`def f(a, b)`.
509514

510515
.. confval:: check_untyped_defs
511516

mypy/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,8 @@ def add_invertible_flag(
696696
"--disallow-incomplete-defs",
697697
default=False,
698698
strict_flag=True,
699-
help="Disallow defining functions with incomplete type annotations",
699+
help="Disallow defining functions with incomplete type annotations "
700+
"(while still allowing entirely unannotated definitions)",
700701
group=untyped_group,
701702
)
702703
add_invertible_flag(

0 commit comments

Comments
 (0)