Skip to content

Commit 1abe75e

Browse files
committed
stubtest: make the --ignore-disjoint-bases hack less inconsistent
1 parent 3c69535 commit 1abe75e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

mypy/stubtest.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ def is_positional_only_related(self) -> bool:
140140
# TODO: This is hacky, use error codes or something more resilient
141141
return "should be positional" in self.message
142142

143+
def is_disjoint_base_related(self) -> bool:
144+
"""Whether or not the error is related to @disjoint_base."""
145+
# TODO: This is hacky, use error codes or something more resilient
146+
return "@disjoint_base" in self.message
147+
143148
def get_description(self, concise: bool = False) -> str:
144149
"""Returns a description of the error.
145150
@@ -630,11 +635,7 @@ def verify_typeinfo(
630635
return
631636

632637
yield from _verify_final(stub, runtime, object_path)
633-
634-
# TODO: Once PEP 800 gets accepted, remove the conditional (always verify)
635-
if "--ignore-disjoint-bases" not in sys.argv[1:]:
636-
yield from _verify_disjoint_base(stub, runtime, object_path)
637-
638+
yield from _verify_disjoint_base(stub, runtime, object_path)
638639
is_runtime_typeddict = stub.typeddict_type is not None and is_typeddict(runtime)
639640
yield from _verify_metaclass(
640641
stub, runtime, object_path, is_runtime_typeddict=is_runtime_typeddict
@@ -2185,6 +2186,7 @@ class _Arguments:
21852186
concise: bool
21862187
ignore_missing_stub: bool
21872188
ignore_positional_only: bool
2189+
ignore_disjoint_bases: bool
21882190
allowlist: list[str]
21892191
generate_allowlist: bool
21902192
ignore_unused_allowlist: bool
@@ -2278,6 +2280,8 @@ def warning_callback(msg: str) -> None:
22782280
continue
22792281
if args.ignore_positional_only and error.is_positional_only_related():
22802282
continue
2283+
if args.ignore_disjoint_bases and error.is_disjoint_base_related():
2284+
continue
22812285
if error.object_desc in allowlist:
22822286
allowlist[error.object_desc] = True
22832287
continue

0 commit comments

Comments
 (0)