Skip to content

Commit

Permalink
fix(check-project): install mypy in temp virtual environment (#25)
Browse files Browse the repository at this point in the history
* fix(check-project): install mypy in temp directory during check-project

* bump version to 1.1.5
  • Loading branch information
DavidVujic authored Jan 6, 2023
1 parent d11d9b8 commit af547fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 8 additions & 3 deletions poetry_multiproject_plugin/commands/checkproject/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
command_name = "check-project"


def run_check(destination: Path, pyproj: str, config_file: str) -> List[str]:
def run_check(
destination: Path, pyproj: str, is_verbose: bool, config_file: str
) -> List[str]:
paths = read.package_paths(destination / pyproj)

rows = [check_for_errors(destination, str(path), config_file) for path in paths]
rows = [
check_for_errors(destination, str(path), is_verbose, config_file)
for path in paths
]
flattened = itertools.chain.from_iterable(rows)

dest = str(destination)
Expand Down Expand Up @@ -73,7 +78,7 @@ def handle(self):
install_deps(project_path, is_verbose)

mypy_config = self.option("config-file")
res = run_check(project_path, "pyproject.toml", mypy_config)
res = run_check(project_path, "pyproject.toml", is_verbose, mypy_config)

if not is_verbose:
self.io.set_verbosity(Verbosity.NORMAL)
Expand Down
9 changes: 8 additions & 1 deletion poetry_multiproject_plugin/components/check/mypy_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
]


def install(is_verbose: bool):
args = [] if is_verbose else ["--quiet"]
cmd = ["poetry", "add", "mypy"] + args
subprocess.run(cmd)


def run(dest: Path, top_ns: str, config_file: Union[str, None]) -> List[str]:
args = ["--config-file", config_file] if config_file else default_args
cmd = ["poetry", "run", "mypy"] + args + [f"{dest}/{top_ns}"]
Expand All @@ -25,12 +31,13 @@ def navigate_to(path: Path):


def check_for_errors(
destination: Path, top_ns: str, config_file: Union[str, None]
destination: Path, top_ns: str, is_verbose: bool, config_file: Union[str, None]
) -> List[str]:
current_dir = Path.cwd()

navigate_to(destination)

install(is_verbose)
lines = run(destination, top_ns, config_file)

navigate_to(current_dir)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetry-multiproject-plugin"
version = "1.1.4"
version = "1.1.5"
description = "A Poetry plugin that makes it possible to use relative package includes."
authors = ["David Vujic"]
homepage = "https://github.com/davidvujic/poetry-multiproject-plugin"
Expand Down

0 comments on commit af547fd

Please sign in to comment.