Skip to content

Commit 6b4e92c

Browse files
committed
Avoid in place modification of __all__ in _get_all_public_members
1 parent a748bfa commit 6b4e92c

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

array_api_compat/_internal.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ def func(x, /, xp, kwarg=None):
2222
arguments.
2323
2424
"""
25+
2526
def inner(f):
2627
@wraps(f)
2728
def wrapped_f(*args, **kwargs):
2829
return f(*args, xp=xp, **kwargs)
2930

3031
sig = signature(f)
31-
new_sig = sig.replace(parameters=[sig.parameters[i] for i in sig.parameters if i != 'xp'])
32+
new_sig = sig.replace(
33+
parameters=[sig.parameters[i] for i in sig.parameters if i != "xp"]
34+
)
3235

3336
if wrapped_f.__doc__ is None:
3437
wrapped_f.__doc__ = f"""\
@@ -46,7 +49,7 @@ def wrapped_f(*args, **kwargs):
4649

4750
def _get_all_public_members(module, exclude=None, extend_all=False):
4851
"""Get all public members of a module.
49-
52+
5053
Parameters
5154
----------
5255
module : module
@@ -58,15 +61,15 @@ def _get_all_public_members(module, exclude=None, extend_all=False):
5861
If True, extend the module's __all__ attribute with the members of the
5962
module derive from dir(module)
6063
"""
61-
members = getattr(module, '__all__', [])
64+
members = getattr(module, "__all__", [])
6265

6366
if members and not extend_all:
6467
return members
6568

6669
if exclude is None:
67-
exclude = lambda name: name.startswith('_') # noqa: E731
70+
exclude = lambda name: name.startswith("_") # noqa: E731
6871

69-
members += [_ for _ in dir(module) if not exclude(_)]
72+
members = members + [_ for _ in dir(module) if not exclude(_)]
7073

7174
# remove duplicates
72-
return list(set(members))
75+
return list(set(members))

0 commit comments

Comments
 (0)