Skip to content

Generalize MypyResults.from_mypy #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading