Skip to content

Commit c5f40d3

Browse files
committed
Moved none_as to _functools.
1 parent f7bdf7c commit c5f40d3

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

zipp/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .compat.py310 import text_encoding
2121
from .glob import Translator
2222

23-
from ._functools import save_method_args
23+
from ._functools import save_method_args, none_as
2424

2525

2626
__all__ = ['Path']
@@ -204,10 +204,6 @@ def _extract_text_encoding(encoding=None, *args, **kwargs):
204204
return text_encoding(encoding, stack_level), args, kwargs
205205

206206

207-
def none_as(value, replacement=None):
208-
return replacement if value is None else value
209-
210-
211207
class Path:
212208
"""
213209
A :class:`importlib.resources.abc.Traversable` interface for zip files.

zipp/_functools.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,14 @@ def wrapper(self, /, *args, **kwargs):
1818
return method(self, *args, **kwargs)
1919

2020
return wrapper
21+
22+
23+
# from jaraco.functools 4.3
24+
def none_as(value, replacement=None):
25+
"""
26+
>>> none_as(None, 'foo')
27+
'foo'
28+
>>> none_as('bar', 'foo')
29+
'bar'
30+
"""
31+
return replacement if value is None else value

0 commit comments

Comments
 (0)