Skip to content

Enable --check-untyped-defs by default #12901

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

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
15 changes: 8 additions & 7 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,12 +669,13 @@ def add_invertible_flag(
group=disallow_any_group,
)

# TODO: is the Note really helpful if --check-untyped-defs is enabled by default? (Maybe
# reword it to emphasize that mypy doesn't infer return types?)
untyped_group = parser.add_argument_group(
title="Untyped definitions and calls",
description="Configure how untyped definitions and calls are handled. "
"Note: by default, mypy ignores any untyped function definitions "
"and assumes any calls to such functions have a return "
"type of 'Any'.",
"Note: by default, mypy assumes any calls to untyped "
"functions have a return type of 'Any'."
)
add_invertible_flag(
"--disallow-untyped-calls",
Expand All @@ -700,10 +701,10 @@ def add_invertible_flag(
group=untyped_group,
)
add_invertible_flag(
"--check-untyped-defs",
default=False,
strict_flag=True,
help="Type check the interior of functions without type annotations",
"--no-check-untyped-defs",
default=True,
dest='check_untyped_defs',
help="Don't type check the interior of functions without type annotations",
group=untyped_group,
)
add_invertible_flag(
Expand Down
2 changes: 1 addition & 1 deletion mypy/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def __init__(self) -> None:
self.disallow_incomplete_defs = False

# Type check unannotated functions
self.check_untyped_defs = False
self.check_untyped_defs = True

# Disallow decorating typed functions with untyped decorators
self.disallow_untyped_decorators = False
Expand Down