File tree Expand file tree Collapse file tree 4 files changed +3
-55
lines changed Expand file tree Collapse file tree 4 files changed +3
-55
lines changed Original file line number Diff line number Diff line change 3
3
=========
4
4
Changelog
5
5
=========
6
+ * :feature: `520 `: Remove ``no_positional `` decorator in favor of native
7
+ syntax.
6
8
* :feature: `518 ` Add Python 3.8 to classifiers.
7
9
* :bug: `332 ` More robust handling of server response in ``--skip-existing ``
8
10
* :release: `2.0.0 <2019-09-24> `
Original file line number Diff line number Diff line change @@ -368,30 +368,6 @@ def test_get_password_runtime_error_suppressed(
368
368
assert 'fail!' in str (warning )
369
369
370
370
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
-
395
371
@pytest .mark .parametrize ('repo_url' , [
396
372
"https://pypi.python.org" ,
397
373
"https://testpypi.python.org"
Original file line number Diff line number Diff line change @@ -39,9 +39,9 @@ class Settings:
39
39
Settings(sign=True, username='fakeusername')
40
40
"""
41
41
42
- @utils .no_positional (allow_self = True )
43
42
def __init__ (
44
43
self ,
44
+ * ,
45
45
sign : bool = False ,
46
46
sign_with : Optional [str ] = 'gpg' ,
47
47
identity : Optional [str ] = None ,
Original file line number Diff line number Diff line change @@ -339,33 +339,3 @@ def get_password(
339
339
username ,
340
340
),
341
341
)
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
You can’t perform that action at this time.
0 commit comments