mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-22 08:21:40 +00:00
[utils] Fix join_nonempty
, add **kwargs
to unpack
(#11559)
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.10) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.11) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.13) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.10) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.13) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.9) (push) Waiting to run
Core Tests / Core Tests (windows-latest, pypy-3.10) (push) Waiting to run
Download Tests / Quick Download Tests (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.10) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.11) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.12) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.13) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, 3.9) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, pypy-3.10) (push) Waiting to run
Quick Test / Core Test (push) Waiting to run
Quick Test / Code check (push) Waiting to run
Release (master) / release (push) Waiting to run
Release (master) / publish_pypi (push) Blocked by required conditions
Some checks are pending
CodeQL / Analyze (python) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.10) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.11) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, 3.13) (push) Waiting to run
Core Tests / Core Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.10) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.12) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.13) (push) Waiting to run
Core Tests / Core Tests (windows-latest, 3.9) (push) Waiting to run
Core Tests / Core Tests (windows-latest, pypy-3.10) (push) Waiting to run
Download Tests / Quick Download Tests (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.10) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.11) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.12) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, 3.13) (push) Waiting to run
Download Tests / Full Download Tests (ubuntu-latest, pypy-3.10) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, 3.9) (push) Waiting to run
Download Tests / Full Download Tests (windows-latest, pypy-3.10) (push) Waiting to run
Quick Test / Core Test (push) Waiting to run
Quick Test / Code check (push) Waiting to run
Release (master) / release (push) Waiting to run
Release (master) / publish_pypi (push) Blocked by required conditions
Authored by: Grub4K
This commit is contained in:
parent
f2a4983df7
commit
39d79c9b9c
@ -525,7 +525,7 @@ def test_trim_str(self):
|
||||
def test_unpack(self):
|
||||
assert unpack(lambda *x: ''.join(map(str, x)))([1, 2, 3]) == '123'
|
||||
assert unpack(join_nonempty)([1, 2, 3]) == '1-2-3'
|
||||
assert unpack(join_nonempty(delim=' '))([1, 2, 3]) == '1 2 3'
|
||||
assert unpack(join_nonempty, delim=' ')([1, 2, 3]) == '1 2 3'
|
||||
with pytest.raises(TypeError):
|
||||
unpack(join_nonempty)()
|
||||
with pytest.raises(TypeError):
|
||||
|
@ -72,7 +72,6 @@
|
||||
intlist_to_bytes,
|
||||
iri_to_uri,
|
||||
is_html,
|
||||
join_nonempty,
|
||||
js_to_json,
|
||||
limit_length,
|
||||
locked_file,
|
||||
@ -2158,10 +2157,6 @@ def test_partial_application(self):
|
||||
assert int_or_none(v=10) == 10, 'keyword passed positional should call function'
|
||||
assert int_or_none(scale=0.1)(10) == 100, 'call after partial application should call the function'
|
||||
|
||||
assert callable(join_nonempty(delim=', ')), 'varargs positional should apply partially'
|
||||
assert callable(join_nonempty()), 'varargs positional should apply partially'
|
||||
assert join_nonempty(None, delim=', ') == '', 'passed varargs should call the function'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
@ -216,7 +216,7 @@ def partial_application(func):
|
||||
sig = inspect.signature(func)
|
||||
required_args = [
|
||||
param.name for param in sig.parameters.values()
|
||||
if param.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD, inspect.Parameter.VAR_POSITIONAL)
|
||||
if param.kind in (inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD)
|
||||
if param.default is inspect.Parameter.empty
|
||||
]
|
||||
|
||||
@ -4837,7 +4837,6 @@ def number_of_digits(number):
|
||||
return len('%d' % number)
|
||||
|
||||
|
||||
@partial_application
|
||||
def join_nonempty(*values, delim='-', from_dict=None):
|
||||
if from_dict is not None:
|
||||
values = (traversal.traverse_obj(from_dict, variadic(v)) for v in values)
|
||||
|
@ -452,9 +452,9 @@ def trim(s):
|
||||
return trim
|
||||
|
||||
|
||||
def unpack(func):
|
||||
def unpack(func, **kwargs):
|
||||
@functools.wraps(func)
|
||||
def inner(items, **kwargs):
|
||||
def inner(items):
|
||||
return func(*items, **kwargs)
|
||||
|
||||
return inner
|
||||
|
Loading…
Reference in New Issue
Block a user