Skip to content

Commit 3c9510b

Browse files
committed
Prefer noop for degenerate behavior.
1 parent a36bab9 commit 3c9510b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

importlib_metadata/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
NullFinder,
3636
install,
3737
)
38-
from ._functools import method_cache, pass_none
38+
from ._functools import method_cache, noop, pass_none
3939
from ._itertools import always_iterable, bucket, unique_everseen
4040
from ._meta import PackageMetadata, SimplePath
4141
from ._typing import md_none
@@ -797,9 +797,7 @@ def _clear_after_fork(cached):
797797
Registering ``cache_clear`` with ``os.register_at_fork`` keeps each process
798798
on its own cache.
799799
"""
800-
getattr(os, 'register_at_fork', lambda **kw: None)(
801-
after_in_child=cached.cache_clear,
802-
)
800+
getattr(os, 'register_at_fork', noop)(after_in_child=cached.cache_clear)
803801
return cached
804802

805803

importlib_metadata/_functools.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,12 @@ def wrapper(param, *args, **kwargs):
102102
return func(param, *args, **kwargs)
103103

104104
return wrapper
105+
106+
107+
# From jaraco.functools 4.4
108+
def noop(*args, **kwargs):
109+
"""
110+
A no-operation function that does nothing.
111+
112+
>>> noop(1, 2, three=3)
113+
"""

0 commit comments

Comments
 (0)