Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify difference between disallow_untyped_defs and disallow_incomplete_defs #15247

Merged
merged 3 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -493,14 +493,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