Skip to content

Commit

Permalink
Clarify difference between disallow_untyped_defs and disallow_incompl…
Browse files Browse the repository at this point in the history
…ete_defs (#15247)

Fixes #9963, fixes #12693
  • Loading branch information
ikonst authored May 18, 2023
1 parent 905c2cb commit 2e6d11e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 7 additions & 2 deletions docs/source/command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,17 @@ definitions or calls.
.. option:: --disallow-untyped-defs

This flag reports an error whenever it encounters a function definition
without type annotations.
without type annotations or with incomplete type annotations.
(a superset of :option:`--disallow-incomplete-defs`).

For example, it would report an error for :code:`def f(a, b)` and :code:`def f(a: int, b)`.

.. option:: --disallow-incomplete-defs

This flag reports an error whenever it encounters a partly annotated
function definition.
function definition, while still allowing entirely unannotated definitions.

For example, it would report an error for :code:`def f(a: int, b)` but not :code:`def f(a, b)`.

.. option:: --check-untyped-defs

Expand Down
9 changes: 7 additions & 2 deletions docs/source/config_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -498,14 +498,19 @@ section of the command line docs.
:default: False

Disallows defining functions without type annotations or with incomplete type
annotations.
annotations (a superset of :confval:`disallow_incomplete_defs`).

For example, it would report an error for :code:`def f(a, b)` and :code:`def f(a: int, b)`.

.. confval:: disallow_incomplete_defs

:type: boolean
:default: False

Disallows defining functions with incomplete type annotations.
Disallows defining functions with incomplete type annotations, while still
allowing entirely unannotated definitions.

For example, it would report an error for :code:`def f(a: int, b)` but not :code:`def f(a, b)`.

.. confval:: check_untyped_defs

Expand Down
3 changes: 2 additions & 1 deletion mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,8 @@ def add_invertible_flag(
"--disallow-incomplete-defs",
default=False,
strict_flag=True,
help="Disallow defining functions with incomplete type annotations",
help="Disallow defining functions with incomplete type annotations "
"(while still allowing entirely unannotated definitions)",
group=untyped_group,
)
add_invertible_flag(
Expand Down

0 comments on commit 2e6d11e

Please sign in to comment.