Skip to content

Commit 143df30

Browse files
committed
Project: use list of paths instead of pyright_cmd
1 parent 7543da9 commit 143df30

File tree

3 files changed

+69
-151
lines changed

3 files changed

+69
-151
lines changed

mypy_primer/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def select_projects() -> list[Project]:
118118
if not (p.min_python_version and sys.version_info < p.min_python_version)
119119
)
120120
if ARGS.type_checker == "pyright":
121-
project_iter = iter(p for p in project_iter if p.pyright_cmd is not None)
121+
project_iter = iter(p for p in project_iter if not p.disable_pyright)
122122
if ARGS.project_selector:
123123
project_iter = iter(
124124
p for p in project_iter if re.search(ARGS.project_selector, p.location, flags=re.I)

mypy_primer/model.py

+12-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ class Project:
2525
name_override: str | None = None
2626

2727
mypy_cmd: str
28-
pyright_cmd: str | None
28+
29+
# Whether or not to run pyright on this project
30+
disable_pyright: bool = False
31+
32+
# A list of explicit paths that are passed to the type checker (currently only used for pyright)
33+
paths: list[str] | None = None
2934

3035
install_cmd: str | None = None
3136
deps: list[str] | None = None
@@ -52,8 +57,8 @@ def __repr__(self) -> str:
5257
result = f"Project(location={self.location!r}, mypy_cmd={self.mypy_cmd!r}"
5358
if self.name_override:
5459
result += f", name_override={self.name_override!r}"
55-
if self.pyright_cmd:
56-
result += f", pyright_cmd={self.pyright_cmd!r}"
60+
if self.paths:
61+
result += f", paths={self.paths!r}"
5762
if self.install_cmd:
5863
result += f", install_cmd={self.install_cmd!r}"
5964
if self.deps:
@@ -245,8 +250,9 @@ async def run_mypy(
245250
)
246251

247252
def get_pyright_cmd(self, pyright: Path, additional_flags: Sequence[str] = ()) -> str:
248-
pyright_cmd = self.pyright_cmd or "{pyright}"
249-
assert "{pyright}" in pyright_cmd
253+
paths = self.paths or []
254+
pyright_cmd = "{pyright} " + " ".join(paths)
255+
250256
if additional_flags:
251257
pyright_cmd += " " + " ".join(additional_flags)
252258
pyright_cmd = pyright_cmd.format(pyright=pyright)
@@ -337,7 +343,7 @@ def from_location(cls, location: str) -> Project:
337343
if header.startswith("# flags:"):
338344
additional_flags = header[len("# flags:") :]
339345
return Project(
340-
location=location, mypy_cmd=f"{{mypy}} {location} {additional_flags}", pyright_cmd=None
346+
location=location, mypy_cmd=f"{{mypy}} {location} {additional_flags}", paths=None
341347
)
342348

343349

0 commit comments

Comments
 (0)