Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove leading underscores from seen and depth args
  • Loading branch information
Bobronium committed Sep 28, 2024
commit c26e978cce86e079a6c0fdfb4ab615952536955f
16 changes: 8 additions & 8 deletions Lib/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,19 +1237,19 @@ def _update_func_cell_for__class__(f, oldcls, newcls):
return False


def _find_inner_functions(obj, _seen=None, _depth=0):
if _seen is None:
_seen = set()
if id(obj) in _seen:
def _find_inner_functions(obj, seen=None, depth=0):
if seen is None:
seen = set()
if id(obj) in seen:
return None
_seen.add(id(obj))
seen.add(id(obj))

_depth += 1
depth += 1
# Normally just an inspection of a descriptor object itself should be enough,
# and we should encounter the function as its attribute,
# but in case function was wrapped (e.g. functools.partial was used),
# we want to dive at least one level deeper.
if _depth > 2:
if depth > 2:
return None

for attr in dir(obj):
Expand All @@ -1259,7 +1259,7 @@ def _find_inner_functions(obj, _seen=None, _depth=0):
if isinstance(value, types.FunctionType):
yield inspect.unwrap(value)
return
yield from _find_inner_functions(value, _seen, _depth)
yield from _find_inner_functions(value, seen, depth)


def _create_slots(defined_fields, inherited_slots, field_names, weakref_slot):
Expand Down