Skip to content

Commit

Permalink
typing: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Nov 24, 2019
1 parent d7d5cf4 commit bc72825
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/_pytest/fixtures.py
Expand Up @@ -36,6 +36,7 @@
from typing import Type

from _pytest import nodes
from _pytest.main import Session


@attr.s(frozen=True)
Expand All @@ -44,7 +45,7 @@ class PseudoFixtureDef:
scope = attr.ib()


def pytest_sessionstart(session):
def pytest_sessionstart(session: "Session"):
import _pytest.python
import _pytest.nodes

Expand Down Expand Up @@ -510,13 +511,11 @@ def _get_fixturestack(self):
values.append(fixturedef)
current = current._parent_request

def _compute_fixture_value(self, fixturedef):
def _compute_fixture_value(self, fixturedef: "FixtureDef") -> None:
"""
Creates a SubRequest based on "self" and calls the execute method of the given fixturedef object. This will
force the FixtureDef object to throw away any previous results and compute a new fixture value, which
will be stored into the FixtureDef object itself.
:param FixtureDef fixturedef:
"""
# prepare a subrequest object before calling fixture function
# (latter managed by fixturedef)
Expand Down Expand Up @@ -544,9 +543,8 @@ def _compute_fixture_value(self, fixturedef):
if has_params:
frame = inspect.stack()[3]
frameinfo = inspect.getframeinfo(frame[0])
source_path = frameinfo.filename
source_path = py.path.local(frameinfo.filename)
source_lineno = frameinfo.lineno
source_path = py.path.local(source_path)
if source_path.relto(funcitem.config.rootdir):
source_path = source_path.relto(funcitem.config.rootdir)
msg = (
Expand Down
2 changes: 2 additions & 0 deletions src/_pytest/main.py
Expand Up @@ -15,6 +15,7 @@
from _pytest.config import directory_arg
from _pytest.config import hookimpl
from _pytest.config import UsageError
from _pytest.fixtures import FixtureManager
from _pytest.outcomes import exit
from _pytest.runner import collect_one_node
from _pytest.runner import SetupState
Expand Down Expand Up @@ -372,6 +373,7 @@ class Session(nodes.FSCollector):
Interrupted = Interrupted
Failed = Failed
_setupstate = None # type: SetupState
_fixturemanager = None # type: FixtureManager

def __init__(self, config):
nodes.FSCollector.__init__(
Expand Down

0 comments on commit bc72825

Please sign in to comment.