Skip to content

Commit ee3c27b

Browse files
committed
Merge remote-tracking branch 'origin/master' into mypy-coverage
2 parents 04cdc41 + 485f657 commit ee3c27b

File tree

4 files changed

+3
-55
lines changed

4 files changed

+3
-55
lines changed

docs/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
=========
44
Changelog
55
=========
6+
* :feature:`520`: Remove ``no_positional`` decorator in favor of native
7+
syntax.
68
* :feature:`518` Add Python 3.8 to classifiers.
79
* :bug:`332` More robust handling of server response in ``--skip-existing``
810
* :release:`2.0.0 <2019-09-24>`

tests/test_utils.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -368,30 +368,6 @@ def test_get_password_runtime_error_suppressed(
368368
assert 'fail!' in str(warning)
369369

370370

371-
def test_no_positional_on_method():
372-
class T:
373-
@utils.no_positional(allow_self=True)
374-
def __init__(self, foo=False):
375-
self.foo = foo
376-
377-
with pytest.raises(TypeError):
378-
T(1)
379-
380-
t = T(foo=True)
381-
assert t.foo
382-
383-
384-
def test_no_positional_on_function():
385-
@utils.no_positional()
386-
def t(foo=False):
387-
return foo
388-
389-
with pytest.raises(TypeError):
390-
t(1)
391-
392-
assert t(foo=True)
393-
394-
395371
@pytest.mark.parametrize('repo_url', [
396372
"https://pypi.python.org",
397373
"https://testpypi.python.org"

twine/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class Settings:
3939
Settings(sign=True, username='fakeusername')
4040
"""
4141

42-
@utils.no_positional(allow_self=True)
4342
def __init__(
4443
self,
44+
*,
4545
sign: bool = False,
4646
sign_with: Optional[str] = 'gpg',
4747
identity: Optional[str] = None,

twine/utils.py

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -339,33 +339,3 @@ def get_password(
339339
username,
340340
),
341341
)
342-
343-
344-
# TODO: Replace this with Python 3 keyword-only arguments
345-
# See https://github.com/pypa/twine/issues/520
346-
def no_positional(allow_self: bool = False) -> Callable:
347-
"""A decorator that doesn't allow for positional arguments.
348-
349-
:param bool allow_self:
350-
Whether to allow ``self`` as a positional argument.
351-
"""
352-
def reject_positional_args(function):
353-
@functools.wraps(function)
354-
def wrapper(*args, **kwargs):
355-
allowed_positional_args = 0
356-
if allow_self:
357-
allowed_positional_args = 1
358-
received_positional_args = len(args)
359-
if received_positional_args > allowed_positional_args:
360-
function_name = function.__name__
361-
verb = 'were' if received_positional_args > 1 else 'was'
362-
raise TypeError(('{}() takes {} positional arguments but {} '
363-
'{} given').format(
364-
function_name,
365-
allowed_positional_args,
366-
received_positional_args,
367-
verb,
368-
))
369-
return function(*args, **kwargs)
370-
return wrapper
371-
return reject_positional_args

0 commit comments

Comments
 (0)