Skip to content

Commit f66741c

Browse files
authored
Enable ruff SIM101 duplicate isinstance check (#18679)
Enforce no unnecessary duplicate isinstance calls (that could be merged into a tuple call).
1 parent a26d8d0 commit f66741c

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

mypy/stubtest.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,15 @@ def is_probably_private(name: str) -> bool:
15341534

15351535
def is_probably_a_function(runtime: Any) -> bool:
15361536
return (
1537-
isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType))
1538-
or isinstance(runtime, (types.MethodType, types.BuiltinMethodType))
1537+
isinstance(
1538+
runtime,
1539+
(
1540+
types.FunctionType,
1541+
types.BuiltinFunctionType,
1542+
types.MethodType,
1543+
types.BuiltinMethodType,
1544+
),
1545+
)
15391546
or (inspect.ismethoddescriptor(runtime) and callable(runtime))
15401547
or (isinstance(runtime, types.MethodWrapperType) and callable(runtime))
15411548
)

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ select = [
144144
"PGH004", # blanket noqa comments
145145
"UP", # pyupgrade
146146
"C4", # flake8-comprehensions
147+
"SIM101", # merge duplicate isinstance calls
147148
"SIM201", "SIM202", "SIM222", "SIM223", # flake8-simplify
148149
"FURB188", # use str.remove(pre|suf)fix
149150
"ISC001", # implicitly concatenated string

0 commit comments

Comments
 (0)