@@ -564,26 +564,19 @@ class Argument:
564
564
'float' : float ,
565
565
'complex' : complex ,
566
566
}
567
- # enable after some grace period for plugin writers
568
- TYPE_WARN = False
569
567
570
568
def __init__ (self , * names , ** attrs ):
571
569
"""store parms in private vars for use in add_argument"""
572
570
self ._attrs = attrs
573
571
self ._short_opts = []
574
572
self ._long_opts = []
575
573
self .dest = attrs .get ('dest' )
576
- if self .TYPE_WARN :
577
- try :
578
- help = attrs ['help' ]
579
- if '%default' in help :
580
- warnings .warn (
581
- 'pytest now uses argparse. "%default" should be'
582
- ' changed to "%(default)s" ' ,
583
- FutureWarning ,
584
- stacklevel = 3 )
585
- except KeyError :
586
- pass
574
+ if '%default' in (attrs .get ('help' ) or '' ):
575
+ warnings .warn (
576
+ 'pytest now uses argparse. "%default" should be'
577
+ ' changed to "%(default)s" ' ,
578
+ DeprecationWarning ,
579
+ stacklevel = 3 )
587
580
try :
588
581
typ = attrs ['type' ]
589
582
except KeyError :
@@ -592,25 +585,23 @@ def __init__(self, *names, **attrs):
592
585
# this might raise a keyerror as well, don't want to catch that
593
586
if isinstance (typ , py .builtin ._basestring ):
594
587
if typ == 'choice' :
595
- if self .TYPE_WARN :
596
- warnings .warn (
597
- 'type argument to addoption() is a string %r.'
598
- ' For parsearg this is optional and when supplied '
599
- ' should be a type.'
600
- ' (options: %s)' % (typ , names ),
601
- FutureWarning ,
602
- stacklevel = 3 )
588
+ warnings .warn (
589
+ 'type argument to addoption() is a string %r.'
590
+ ' For parsearg this is optional and when supplied '
591
+ ' should be a type.'
592
+ ' (options: %s)' % (typ , names ),
593
+ DeprecationWarning ,
594
+ stacklevel = 3 )
603
595
# argparse expects a type here take it from
604
596
# the type of the first element
605
597
attrs ['type' ] = type (attrs ['choices' ][0 ])
606
598
else :
607
- if self .TYPE_WARN :
608
- warnings .warn (
609
- 'type argument to addoption() is a string %r.'
610
- ' For parsearg this should be a type.'
611
- ' (options: %s)' % (typ , names ),
612
- FutureWarning ,
613
- stacklevel = 3 )
599
+ warnings .warn (
600
+ 'type argument to addoption() is a string %r.'
601
+ ' For parsearg this should be a type.'
602
+ ' (options: %s)' % (typ , names ),
603
+ DeprecationWarning ,
604
+ stacklevel = 3 )
614
605
attrs ['type' ] = Argument ._typ_map [typ ]
615
606
# used in test_parseopt -> test_parse_defaultgetter
616
607
self .type = attrs ['type' ]
0 commit comments