Fix check_untyped_defs errors in cacheprovider

This commit is contained in:
Ran Benita 2019-09-13 22:49:47 +03:00
parent 93c8822f26
commit 5dca7a2f4f
1 changed files with 9 additions and 3 deletions

View File

@ -7,6 +7,7 @@ ignores the external pytest-cache
import json import json
import os import os
from collections import OrderedDict from collections import OrderedDict
from typing import List
import attr import attr
import py import py
@ -15,6 +16,9 @@ import pytest
from .pathlib import Path from .pathlib import Path
from .pathlib import resolve_from_str from .pathlib import resolve_from_str
from .pathlib import rm_rf from .pathlib import rm_rf
from _pytest import nodes
from _pytest.config import Config
from _pytest.main import Session
README_CONTENT = """\ README_CONTENT = """\
# pytest cache directory # # pytest cache directory #
@ -263,10 +267,12 @@ class NFPlugin:
self.active = config.option.newfirst self.active = config.option.newfirst
self.cached_nodeids = config.cache.get("cache/nodeids", []) self.cached_nodeids = config.cache.get("cache/nodeids", [])
def pytest_collection_modifyitems(self, session, config, items): def pytest_collection_modifyitems(
self, session: Session, config: Config, items: List[nodes.Item]
) -> None:
if self.active: if self.active:
new_items = OrderedDict() new_items = OrderedDict() # type: OrderedDict[str, nodes.Item]
other_items = OrderedDict() other_items = OrderedDict() # type: OrderedDict[str, nodes.Item]
for item in items: for item in items:
if item.nodeid not in self.cached_nodeids: if item.nodeid not in self.cached_nodeids:
new_items[item.nodeid] = item new_items[item.nodeid] = item