MCPcopy Index your code
hub / github.com/RustPython/RustPython / pass_none

Function pass_none

Lib/importlib/metadata/_functools.py:89–104  ·  view source on GitHub ↗

Wrap func so it's not called if its first param is None >>> print_text = pass_none(print) >>> print_text('text') text >>> print_text(None)

(func)

Source from the content-addressed store, hash-verified

87
88# From jaraco.functools 3.3
89def pass_none(func):
90 """
91 Wrap func so it's not called if its first param is None
92
93 >>> print_text = pass_none(print)
94 >>> print_text('text')
95 text
96 >>> print_text(None)
97 """
98
99 @functools.wraps(func)
100 def wrapper(param, *args, **kwargs):
101 if param is not None:
102 return func(param, *args, **kwargs)
103
104 return wrapper

Callers 3

_read_egg_info_reqsMethod · 0.85
_load_jsonMethod · 0.85
_normalized_nameMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected