main: better solution to a type ignore

This commit is contained in:
Ran Benita 2020-08-21 10:47:29 +03:00
parent 57aca11d4a
commit 0b41b79dcb
1 changed files with 3 additions and 4 deletions

View File

@ -597,10 +597,11 @@ class Session(nodes.FSCollector):
self._notfound = [] # type: List[Tuple[str, NoMatch]] self._notfound = [] # type: List[Tuple[str, NoMatch]]
self._initial_parts = [] # type: List[Tuple[py.path.local, List[str]]] self._initial_parts = [] # type: List[Tuple[py.path.local, List[str]]]
self.items = items = [] # type: List[nodes.Item] self.items = [] # type: List[nodes.Item]
hook = self.config.hook hook = self.config.hook
items = self.items # type: Sequence[Union[nodes.Item, nodes.Collector]]
try: try:
initialpaths = [] # type: List[py.path.local] initialpaths = [] # type: List[py.path.local]
for arg in args: for arg in args:
@ -620,9 +621,7 @@ class Session(nodes.FSCollector):
errors.append("not found: {}\n{}".format(arg, line)) errors.append("not found: {}\n{}".format(arg, line))
raise UsageError(*errors) raise UsageError(*errors)
if not genitems: if not genitems:
# Type ignored because genitems=False is only used by tests. We don't items = rep.result
# want to change the type of `session.items` for this case.
items = rep.result # type: ignore[assignment]
else: else:
if rep.passed: if rep.passed:
for node in rep.result: for node in rep.result: