Skip to content
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

Fix windows support for mypy_primer --coverage #110

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
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
12 changes: 10 additions & 2 deletions mypy_primer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ def select_projects() -> list[Project]:
if ARGS.project_date:
project_iter = (replace(p, revision=ARGS.project_date) for p in project_iter)

projects = list(project_iter)
projects = [
p
for p in project_iter
if p.supported_platforms is None or sys.platform in p.supported_platforms
]
if projects == []:
raise ValueError("No projects selected!")

Expand Down Expand Up @@ -300,7 +304,11 @@ async def coverage() -> None:
)

projects = select_projects()
mypy_python = mypy_exe.parent / "python"
if sys.platform == "win32":
mypy_python = mypy_exe.parent / "python.exe"
else:
mypy_python = mypy_exe.parent / "python"

assert mypy_python.exists()

all_paths = await asyncio.gather(*[
Expand Down
6 changes: 5 additions & 1 deletion mypy_primer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class Project:

name_override: str | None = None

supported_platforms: list[str] | None = None

# custom __repr__ that omits defaults.
def __repr__(self) -> str:
result = f"Project(location={self.location!r}, mypy_cmd={self.mypy_cmd!r}"
Expand All @@ -58,6 +60,8 @@ def __repr__(self) -> str:
result += f", min_python_version={self.min_python_version!r}"
if self.name_override:
result += f", name_override={self.name_override!r}"
if self.supported_platforms:
result += f", supported_platforms={self.supported_platforms!r}"
result += ")"
return result

Expand Down Expand Up @@ -265,7 +269,7 @@ async def mypy_source_paths(self, mypy_python: str) -> list[Path]:
"""
# the extra shell stuff here makes sure we expand globs in mypy_cmd
proc, _ = await run(
f"{mypy_python} -c {shlex.quote(program)} {mypy_cmd}",
f"{mypy_python} -c {quote_path(program)} {mypy_cmd}",
output=True,
cwd=ctx.get().projects_dir / self.name,
shell=True,
Expand Down
9 changes: 9 additions & 0 deletions mypy_primer/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def get_projects() -> list[Project]:
mypy_cmd="{mypy} aiohttp",
pip_cmd="AIOHTTP_NO_EXTENSIONS=1 {pip} install -e . pytest",
expected_mypy_success=True,
supported_platforms=["linux", "darwin"],
),
Project(
location="https://github.com/python-attrs/attrs",
Expand Down Expand Up @@ -144,6 +145,7 @@ def get_projects() -> list[Project]:
mypy_cmd="{mypy} boostedblob",
pip_cmd="{pip} install aiohttp uvloop pycryptodome",
expected_mypy_success=True,
supported_platforms=["linux", "darwin"],
),
Project(
location="https://github.com/quora/asynq",
Expand Down Expand Up @@ -227,6 +229,7 @@ def get_projects() -> list[Project]:
" types-pytz types-PyYAML types-requests"
),
expected_mypy_success=True,
supported_platforms=["linux", "darwin"],
),
Project(
location="https://github.com/PrefectHQ/prefect",
Expand Down Expand Up @@ -338,6 +341,7 @@ def get_projects() -> list[Project]:
mypy_cmd="{mypy} src/schemathesis",
pip_cmd="{pip} install attrs types-requests types-PyYAML",
expected_mypy_success=True,
supported_platforms=["linux", "darwin"],
),
Project(
location="https://github.com/graphql-python/graphql-core",
Expand Down Expand Up @@ -588,6 +592,7 @@ def get_projects() -> list[Project]:
mypy_cmd="{mypy} .",
pip_cmd="{pip} install types-Pillow types-cachetools types-requests attrs",
expected_mypy_success=True,
supported_platforms=["linux", "darwin"],
),
Project(
location="https://github.com/sco1/pylox",
Expand Down Expand Up @@ -890,4 +895,8 @@ def get_projects() -> list[Project]:
),
]
assert len(projects) == len({p.name for p in projects})
for p in projects:
assert p.supported_platforms is None or all(
p in ("linux", "darwin") for p in p.supported_platforms
)
return projects