6
6
import os
7
7
import sys
8
8
from typing import Dict
9
+ from typing import FrozenSet
10
+ from typing import List
9
11
10
12
import attr
11
13
import py
12
14
13
15
import _pytest ._code
14
16
from _pytest import nodes
17
+ from _pytest .compat import TYPE_CHECKING
18
+ from _pytest .config import Config
15
19
from _pytest .config import directory_arg
16
20
from _pytest .config import hookimpl
17
21
from _pytest .config import UsageError
18
22
from _pytest .fixtures import FixtureManager
23
+ from _pytest .nodes import Node
19
24
from _pytest .outcomes import exit
20
25
from _pytest .runner import collect_one_node
21
26
from _pytest .runner import SetupState
22
27
23
28
29
+ if TYPE_CHECKING :
30
+ from _pytest .python import Package
31
+
32
+
24
33
class ExitCode (enum .IntEnum ):
25
34
"""
26
35
.. versionadded:: 5.0
@@ -383,7 +392,7 @@ class Session(nodes.FSCollector):
383
392
# Set on the session by fixtures.pytest_sessionstart.
384
393
_fixturemanager = None # type: FixtureManager
385
394
386
- def __init__ (self , config ) :
395
+ def __init__ (self , config : Config ) -> None :
387
396
nodes .FSCollector .__init__ (
388
397
self , config .rootdir , parent = None , config = config , session = self , nodeid = ""
389
398
)
@@ -394,14 +403,16 @@ def __init__(self, config):
394
403
self .trace = config .trace .root .get ("collection" )
395
404
self ._norecursepatterns = config .getini ("norecursedirs" )
396
405
self .startdir = config .invocation_dir
397
- self ._initialpaths = frozenset ()
406
+ self ._initialpaths = frozenset () # type: FrozenSet[py.path.local]
407
+
398
408
# Keep track of any collected nodes in here, so we don't duplicate fixtures
399
- self ._node_cache = {}
409
+ self ._node_cache = {} # type: Dict[str, List[Node]]
410
+ # Dirnames of pkgs with dunder-init files.
411
+ self ._pkg_roots = {} # type: Dict[py.path.local, Package]
412
+
400
413
self ._bestrelpathcache = _bestrelpath_cache (
401
414
config .rootdir
402
415
) # type: Dict[str, str]
403
- # Dirnames of pkgs with dunder-init files.
404
- self ._pkg_roots = {}
405
416
406
417
self .config .pluginmanager .register (self , name = "session" )
407
418
0 commit comments