Skip to content

Commit

Permalink
Make disallow-any-unimported flag invertible
Browse files Browse the repository at this point in the history
  • Loading branch information
soceanainn committed Oct 24, 2024
1 parent 3420ef1 commit e7d709b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
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(
"--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]
# 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

0 comments on commit e7d709b

Please sign in to comment.