From af547fd44b4446616570fb30f5dd0108b450ff87 Mon Sep 17 00:00:00 2001 From: David Vujic Date: Fri, 6 Jan 2023 17:35:34 +0100 Subject: [PATCH] fix(check-project): install mypy in temp virtual environment (#25) * fix(check-project): install mypy in temp directory during check-project * bump version to 1.1.5 --- .../commands/checkproject/check.py | 11 ++++++++--- .../components/check/mypy_checker.py | 9 ++++++++- pyproject.toml | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/poetry_multiproject_plugin/commands/checkproject/check.py b/poetry_multiproject_plugin/commands/checkproject/check.py index fd4f45e..fa4a990 100644 --- a/poetry_multiproject_plugin/commands/checkproject/check.py +++ b/poetry_multiproject_plugin/commands/checkproject/check.py @@ -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) @@ -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) diff --git a/poetry_multiproject_plugin/components/check/mypy_checker.py b/poetry_multiproject_plugin/components/check/mypy_checker.py index faef6ad..8b25e1a 100644 --- a/poetry_multiproject_plugin/components/check/mypy_checker.py +++ b/poetry_multiproject_plugin/components/check/mypy_checker.py @@ -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}"] @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 869816a..a55e6ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"