Skip to content

Commit 8638eb4

Browse files
jorenhamKevin Kannammalil
authored andcommitted
[stubtest] temporary --ignore-disjoint-bases flag (#19740)
closes #19737 ref: #19737 (comment) --- It's not the prettiest code, but since it will be removed once PEP 800 gets accepted (or rejected), I figured it would be best to keep it simple, so that we can easily revert it.
1 parent acacc9e commit 8638eb4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mypy/stubtest.py

Lines changed: 14 additions & 0 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
@@ -2181,6 +2186,7 @@ class _Arguments:
21812186
concise: bool
21822187
ignore_missing_stub: bool
21832188
ignore_positional_only: bool
2189+
ignore_disjoint_bases: bool
21842190
allowlist: list[str]
21852191
generate_allowlist: bool
21862192
ignore_unused_allowlist: bool
@@ -2274,6 +2280,8 @@ def warning_callback(msg: str) -> None:
22742280
continue
22752281
if args.ignore_positional_only and error.is_positional_only_related():
22762282
continue
2283+
if args.ignore_disjoint_bases and error.is_disjoint_base_related():
2284+
continue
22772285
if error.object_desc in allowlist:
22782286
allowlist[error.object_desc] = True
22792287
continue
@@ -2364,6 +2372,12 @@ def parse_options(args: list[str]) -> _Arguments:
23642372
action="store_true",
23652373
help="Ignore errors for whether an argument should or shouldn't be positional-only",
23662374
)
2375+
# TODO: Remove once PEP 800 is accepted
2376+
parser.add_argument(
2377+
"--ignore-disjoint-bases",
2378+
action="store_true",
2379+
help="Disable checks for PEP 800 @disjoint_base classes",
2380+
)
23672381
parser.add_argument(
23682382
"--allowlist",
23692383
"--whitelist",

0 commit comments

Comments
 (0)