@@ -552,31 +552,31 @@ def __str__(self):
552552
553553
554554class Argument :
555- """class that mimics the necessary behaviour of optparse.Option """
555+ """class that mimics the necessary behaviour of optparse.Option
556+
557+ its currently a least effort implementation
558+ and ignoring choices and integer prefixes
559+ https://docs.python.org/3/library/optparse.html#optparse-standard-option-types
560+ """
556561 _typ_map = {
557562 'int' : int ,
558563 'string' : str ,
559- }
560- # enable after some grace period for plugin writers
561- TYPE_WARN = False
564+ 'float' : float ,
565+ 'complex' : complex ,
566+ }
562567
563568 def __init__ (self , * names , ** attrs ):
564569 """store parms in private vars for use in add_argument"""
565570 self ._attrs = attrs
566571 self ._short_opts = []
567572 self ._long_opts = []
568573 self .dest = attrs .get ('dest' )
569- if self .TYPE_WARN :
570- try :
571- help = attrs ['help' ]
572- if '%default' in help :
573- warnings .warn (
574- 'pytest now uses argparse. "%default" should be'
575- ' changed to "%(default)s" ' ,
576- FutureWarning ,
577- stacklevel = 3 )
578- except KeyError :
579- 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 )
580580 try :
581581 typ = attrs ['type' ]
582582 except KeyError :
@@ -585,25 +585,23 @@ def __init__(self, *names, **attrs):
585585 # this might raise a keyerror as well, don't want to catch that
586586 if isinstance (typ , py .builtin ._basestring ):
587587 if typ == 'choice' :
588- if self .TYPE_WARN :
589- warnings .warn (
590- 'type argument to addoption() is a string %r.'
591- ' For parsearg this is optional and when supplied '
592- ' should be a type.'
593- ' (options: %s)' % (typ , names ),
594- FutureWarning ,
595- 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 )
596595 # argparse expects a type here take it from
597596 # the type of the first element
598597 attrs ['type' ] = type (attrs ['choices' ][0 ])
599598 else :
600- if self .TYPE_WARN :
601- warnings .warn (
602- 'type argument to addoption() is a string %r.'
603- ' For parsearg this should be a type.'
604- ' (options: %s)' % (typ , names ),
605- FutureWarning ,
606- 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 )
607605 attrs ['type' ] = Argument ._typ_map [typ ]
608606 # used in test_parseopt -> test_parse_defaultgetter
609607 self .type = attrs ['type' ]
0 commit comments