Skip to content

Commit

Permalink
Generalize MypyResults.from_mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtucker committed Aug 11, 2024
1 parent 379afde commit ed5ed3e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/pytest_mypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def load(cls, results_f: TextIO) -> "MypyResults":
@classmethod
def from_mypy(
cls,
items: List[MypyFileItem],
paths: List[Path],
*,
opts: Optional[List[str]] = None,
) -> "MypyResults":
Expand All @@ -263,7 +263,7 @@ def from_mypy(
if opts is None: # pragma: no cover
opts = mypy_argv[:]
abspath_errors = {
os.path.abspath(str(item.fspath)): [] for item in items
str(path.absolute()): [] for path in paths
} # type: MypyResults._abspath_errors_type

stdout, stderr, status = mypy.api.run(
Expand Down Expand Up @@ -304,7 +304,11 @@ def from_session(cls, session) -> "MypyResults":
results = cls.load(results_f)
except FileNotFoundError:
results = cls.from_mypy(
[item for item in session.items if isinstance(item, MypyFileItem)],
[
Path(item.fspath)
for item in session.items
if isinstance(item, MypyFileItem)
],
)
with open(results_path, mode="w") as results_f:
results.dump(results_f)
Expand Down

0 comments on commit ed5ed3e

Please sign in to comment.