Skip to content
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
12 changes: 6 additions & 6 deletions mypy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,12 +645,6 @@ def add_invertible_flag(
title="Disallow dynamic typing",
description="Disallow the use of the dynamic 'Any' type under certain conditions.",
)
disallow_any_group.add_argument(
"--disallow-any-unimported",
default=False,
action="store_true",
help="Disallow Any types resulting from unfollowed imports",
)
disallow_any_group.add_argument(
"--disallow-any-expr",
default=False,
Expand All @@ -677,6 +671,12 @@ def add_invertible_flag(
help="Disallow usage of generic types that do not specify explicit type parameters",
group=disallow_any_group,
)
add_invertible_flag(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this down ~20 lines or so, as all invertible flags for this group were defined after non-invertible flags prior to now and I wanted to maintain that convention (assuming this was intentional and not just a coincidence)

"--disallow-any-unimported",
default=False,
help="Disallow Any types resulting from unfollowed imports",
group=disallow_any_group,
)
add_invertible_flag(
"--disallow-subclassing-any",
default=False,
Expand Down
6 changes: 6 additions & 0 deletions test-data/unit/check-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,12 @@ from missing import Unchecked

t: Unchecked = 12 # E: Type of variable becomes "Any" due to an unfollowed import

[case testAllowImplicitAnyVariableDefinition]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not fully sure how to test explicitly setting what is already the default behaviour. This test will pass whether or not --allow-any-unimported is set (as long as --disallow-any-unimported is not set).

This is a copy of the test immediately before it. The test before this sets --disallow-any-unimported and asserts that an error occurs, this test sets --allow-any-unimported and asserts no error occurs.

# flags: --ignore-missing-imports --allow-any-unimported
from missing import Unchecked

t: Unchecked = 12

[case testDisallowImplicitAnyGeneric]
# flags: --ignore-missing-imports --disallow-any-unimported
from missing import Unchecked
Expand Down
Loading