45
45
if False : # TYPE_CHECKING
46
46
from typing import Type
47
47
48
+ from .argparsing import Argument
49
+
48
50
49
51
hookimpl = HookimplMarker ("pytest" )
50
52
hookspec = HookspecMarker ("pytest" )
@@ -679,7 +681,7 @@ class InvocationParams:
679
681
plugins = attr .ib ()
680
682
dir = attr .ib (type = Path )
681
683
682
- def __init__ (self , pluginmanager , * , invocation_params = None ):
684
+ def __init__ (self , pluginmanager , * , invocation_params = None ) -> None :
683
685
from .argparsing import Parser , FILE_OR_DIR
684
686
685
687
if invocation_params is None :
@@ -792,19 +794,19 @@ def fromdictargs(cls, option_dict, args):
792
794
config .pluginmanager .consider_pluginarg (x )
793
795
return config
794
796
795
- def _processopt (self , opt ) :
797
+ def _processopt (self , opt : "Argument" ) -> None :
796
798
for name in opt ._short_opts + opt ._long_opts :
797
799
self ._opt2dest [name ] = opt .dest
798
800
799
- if hasattr (opt , "default" ) and opt . dest :
801
+ if hasattr (opt , "default" ):
800
802
if not hasattr (self .option , opt .dest ):
801
803
setattr (self .option , opt .dest , opt .default )
802
804
803
805
@hookimpl (trylast = True )
804
806
def pytest_load_initial_conftests (self , early_config ):
805
807
self .pluginmanager ._set_initial_conftests (early_config .known_args_namespace )
806
808
807
- def _initini (self , args ) -> None :
809
+ def _initini (self , args : Sequence [ str ] ) -> None :
808
810
ns , unknown_args = self ._parser .parse_known_and_unknown_args (
809
811
args , namespace = copy .copy (self .option )
810
812
)
@@ -821,7 +823,7 @@ def _initini(self, args) -> None:
821
823
self ._parser .addini ("minversion" , "minimally required pytest version" )
822
824
self ._override_ini = ns .override_ini or ()
823
825
824
- def _consider_importhook (self , args ) :
826
+ def _consider_importhook (self , args : Sequence [ str ]) -> None :
825
827
"""Install the PEP 302 import hook if using assertion rewriting.
826
828
827
829
Needs to parse the --assert=<mode> option from the commandline
@@ -861,19 +863,19 @@ def _mark_plugins_for_rewrite(self, hook):
861
863
for name in _iter_rewritable_modules (package_files ):
862
864
hook .mark_rewrite (name )
863
865
864
- def _validate_args (self , args , via ) :
866
+ def _validate_args (self , args : List [ str ] , via : str ) -> List [ str ] :
865
867
"""Validate known args."""
866
- self ._parser ._config_source_hint = via
868
+ self ._parser ._config_source_hint = via # type: ignore
867
869
try :
868
870
self ._parser .parse_known_and_unknown_args (
869
871
args , namespace = copy .copy (self .option )
870
872
)
871
873
finally :
872
- del self ._parser ._config_source_hint
874
+ del self ._parser ._config_source_hint # type: ignore
873
875
874
876
return args
875
877
876
- def _preparse (self , args , addopts = True ):
878
+ def _preparse (self , args : List [ str ] , addopts : bool = True ) -> None :
877
879
if addopts :
878
880
env_addopts = os .environ .get ("PYTEST_ADDOPTS" , "" )
879
881
if len (env_addopts ):
@@ -937,7 +939,7 @@ def _checkversion(self):
937
939
)
938
940
)
939
941
940
- def parse (self , args , addopts = True ):
942
+ def parse (self , args : List [ str ] , addopts : bool = True ) -> None :
941
943
# parse given cmdline arguments into this config object.
942
944
assert not hasattr (
943
945
self , "args"
@@ -948,7 +950,7 @@ def parse(self, args, addopts=True):
948
950
self ._preparse (args , addopts = addopts )
949
951
# XXX deprecated hook:
950
952
self .hook .pytest_cmdline_preparse (config = self , args = args )
951
- self ._parser .after_preparse = True
953
+ self ._parser .after_preparse = True # type: ignore
952
954
try :
953
955
args = self ._parser .parse_setoption (
954
956
args , self .option , namespace = self .option
0 commit comments