Skip to content
Closed
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
2 changes: 1 addition & 1 deletion mypy_primer/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def select_projects() -> list[Project]:
if not (p.min_python_version and sys.version_info < p.min_python_version)
)
if ARGS.type_checker == "pyright":
project_iter = iter(p for p in project_iter if p.pyright_cmd is not None)
project_iter = iter(p for p in project_iter if not p.pyright_skip)
if ARGS.project_selector:
project_iter = iter(
p for p in project_iter if re.search(ARGS.project_selector, p.location, flags=re.I)
Expand Down
18 changes: 12 additions & 6 deletions mypy_primer/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ class Project:
name_override: str | None = None

mypy_cmd: str
pyright_cmd: str | None

# Whether or not to run pyright on this project
pyright_skip: bool = False

# A list of explicit paths that are passed to the type checker (currently only used for pyright)
paths: list[str] | None = None

install_cmd: str | None = None
deps: list[str] | None = None
Expand All @@ -52,8 +57,8 @@ def __repr__(self) -> str:
result = f"Project(location={self.location!r}, mypy_cmd={self.mypy_cmd!r}"
if self.name_override:
result += f", name_override={self.name_override!r}"
if self.pyright_cmd:
result += f", pyright_cmd={self.pyright_cmd!r}"
if self.paths:
result += f", paths={self.paths!r}"
if self.install_cmd:
result += f", install_cmd={self.install_cmd!r}"
if self.deps:
Expand Down Expand Up @@ -245,8 +250,9 @@ async def run_mypy(
)

def get_pyright_cmd(self, pyright: Path, additional_flags: Sequence[str] = ()) -> str:
pyright_cmd = self.pyright_cmd or "{pyright}"
assert "{pyright}" in pyright_cmd
paths = self.paths or []
pyright_cmd = "{pyright} " + " ".join(paths)

if additional_flags:
pyright_cmd += " " + " ".join(additional_flags)
pyright_cmd = pyright_cmd.format(pyright=pyright)
Expand Down Expand Up @@ -337,7 +343,7 @@ def from_location(cls, location: str) -> Project:
if header.startswith("# flags:"):
additional_flags = header[len("# flags:") :]
return Project(
location=location, mypy_cmd=f"{{mypy}} {location} {additional_flags}", pyright_cmd=None
location=location, mypy_cmd=f"{{mypy}} {location} {additional_flags}", paths=None
)


Expand Down
Loading