From 09f220a6004d1bd83486570149e451c12a23bddd Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Fri, 14 Feb 2025 11:05:25 -0500 Subject: [PATCH] Enable ruff SIM101 duplicate isinstance check --- mypy/stubtest.py | 11 +++++++++-- pyproject.toml | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/mypy/stubtest.py b/mypy/stubtest.py index 599a24cf685d..41b58cbbb636 100644 --- a/mypy/stubtest.py +++ b/mypy/stubtest.py @@ -1534,8 +1534,15 @@ def is_probably_private(name: str) -> bool: def is_probably_a_function(runtime: Any) -> bool: return ( - isinstance(runtime, (types.FunctionType, types.BuiltinFunctionType)) - or isinstance(runtime, (types.MethodType, types.BuiltinMethodType)) + isinstance( + runtime, + ( + types.FunctionType, + types.BuiltinFunctionType, + types.MethodType, + types.BuiltinMethodType, + ), + ) or (inspect.ismethoddescriptor(runtime) and callable(runtime)) or (isinstance(runtime, types.MethodWrapperType) and callable(runtime)) ) diff --git a/pyproject.toml b/pyproject.toml index 2eaca2d3ea88..58d144c4f886 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -142,6 +142,7 @@ select = [ "PGH004", # blanket noqa comments "UP", # pyupgrade "C4", # flake8-comprehensions + "SIM101", # merge duplicate isinstance calls "SIM201", "SIM202", "SIM222", "SIM223", # flake8-simplify "FURB188", # use str.remove(pre|suf)fix "ISC001", # implicitly concatenated string