MCPcopy Index your code
hub / github.com/python/cpython / pass_none

Function pass_none

Lib/importlib/metadata/_functools.py:91–106  ·  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

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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…