From e7d709b9559ecf098aae58bfc82975d274cf7de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9amus=20=C3=93=20Ceanainn?= Date: Thu, 24 Oct 2024 16:15:22 +0100 Subject: [PATCH] Make disallow-any-unimported flag invertible --- mypy/main.py | 12 ++++++------ test-data/unit/check-flags.test | 6 ++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/mypy/main.py b/mypy/main.py index 5991ddd9e62f0..4860b93400c2e 100644 --- a/mypy/main.py +++ b/mypy/main.py @@ -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, @@ -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, diff --git a/test-data/unit/check-flags.test b/test-data/unit/check-flags.test index dd7bee3f7aec3..c6419923ebc62 100644 --- a/test-data/unit/check-flags.test +++ b/test-data/unit/check-flags.test @@ -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