Skip to content

Commit

Permalink
Merge pull request #6525 from blueyed/typing-session
Browse files Browse the repository at this point in the history
typing: Session.__init__
  • Loading branch information
blueyed authored Jan 22, 2020
2 parents 85df6bb + bd6ba3f commit ad02f6f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@
import os
import sys
from typing import Dict
from typing import FrozenSet
from typing import List

import attr
import py

import _pytest._code
from _pytest import nodes
from _pytest.compat import TYPE_CHECKING
from _pytest.config import Config
from _pytest.config import directory_arg
from _pytest.config import hookimpl
from _pytest.config import UsageError
from _pytest.fixtures import FixtureManager
from _pytest.nodes import Node
from _pytest.outcomes import exit
from _pytest.runner import collect_one_node
from _pytest.runner import SetupState


if TYPE_CHECKING:
from _pytest.python import Package


class ExitCode(enum.IntEnum):
"""
.. versionadded:: 5.0
Expand Down Expand Up @@ -383,7 +392,7 @@ class Session(nodes.FSCollector):
# Set on the session by fixtures.pytest_sessionstart.
_fixturemanager = None # type: FixtureManager

def __init__(self, config):
def __init__(self, config: Config) -> None:
nodes.FSCollector.__init__(
self, config.rootdir, parent=None, config=config, session=self, nodeid=""
)
Expand All @@ -394,14 +403,16 @@ def __init__(self, config):
self.trace = config.trace.root.get("collection")
self._norecursepatterns = config.getini("norecursedirs")
self.startdir = config.invocation_dir
self._initialpaths = frozenset()
self._initialpaths = frozenset() # type: FrozenSet[py.path.local]

# Keep track of any collected nodes in here, so we don't duplicate fixtures
self._node_cache = {}
self._node_cache = {} # type: Dict[str, List[Node]]
# Dirnames of pkgs with dunder-init files.
self._pkg_roots = {} # type: Dict[py.path.local, Package]

self._bestrelpathcache = _bestrelpath_cache(
config.rootdir
) # type: Dict[str, str]
# Dirnames of pkgs with dunder-init files.
self._pkg_roots = {}

self.config.pluginmanager.register(self, name="session")

Expand Down

0 comments on commit ad02f6f

Please sign in to comment.