Skip to content

Commit a298d67

Browse files
committed
Fix ruff SIM101: merge isinstance calls
1 parent e922a70 commit a298d67

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

mypy/types_utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,8 @@ def is_generic_instance(tp: Type) -> bool:
123123

124124
def is_overlapping_none(t: Type) -> bool:
125125
t = get_proper_type(t)
126-
return (
127-
isinstance(t, NoneType)
128-
or isinstance(t, AnyType)
129-
or (
130-
isinstance(t, UnionType)
131-
and any(isinstance(get_proper_type(e), NoneType) for e in t.items)
132-
)
126+
return isinstance(t, (NoneType, AnyType)) or (
127+
isinstance(t, UnionType) and any(isinstance(get_proper_type(e), NoneType) for e in t.items)
133128
)
134129

135130

test-data/unit/check-unreachable-code.test

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,12 +1653,7 @@ main:4: error: Statement is unreachable
16531653

16541654
[case testNoFalseUnreachableWithAnyEqualityNarrowing]
16551655
# flags: --warn-unreachable
1656-
# Regression test for https://github.com/python/mypy/issues/20532
16571656
from typing import Any, Optional
1658-
16591657
def main(contents: Any, commit: Optional[str]) -> None:
1660-
if (
1661-
contents.get("commit") == commit
1662-
and (commit is not None or 1)
1663-
):
1658+
if contents.get("commit") == commit and (commit is not None or 1):
16641659
pass

0 commit comments

Comments
 (0)