Skip to content

Commit 5ed1921

Browse files
AA-Turnerpicnixz
andcommitted
Use sentinel objects in sphinx.util.inspect
Co-authored-by: Bénédikt Tran <[email protected]>
1 parent e352a67 commit 5ed1921

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

sphinx/util/inspect.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,10 @@ def isclassmethod(obj: Any, cls: Any = None, name: str | None = None) -> bool:
219219
return True
220220
if cls and name:
221221
# trace __mro__ if the method is defined in parent class
222+
sentinel = object()
222223
for basecls in getmro(cls):
223-
meth = basecls.__dict__.get(name)
224-
if meth is not None:
224+
meth = basecls.__dict__.get(name, sentinel)
225+
if meth is not sentinel:
225226
return isclassmethod(meth)
226227
return False
227228

@@ -232,9 +233,10 @@ def isstaticmethod(obj: Any, cls: Any = None, name: str | None = None) -> bool:
232233
return True
233234
if cls and name:
234235
# trace __mro__ if the method is defined in parent class
236+
sentinel = object()
235237
for basecls in getattr(cls, '__mro__', [cls]):
236-
meth = basecls.__dict__.get(name)
237-
if meth is not None:
238+
meth = basecls.__dict__.get(name, sentinel)
239+
if meth is not sentinel:
238240
return isinstance(meth, staticmethod)
239241
return False
240242

0 commit comments

Comments
 (0)