diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 514ba4a5a..e4f1cfb23 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -47,13 +47,13 @@ repos: - --rcfile=pylintrc # Link to config file - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.2.0 + rev: v1.4.1 hooks: - id: mypy args: - --config-file=pyproject.toml additional_dependencies: - - pydantic + - pydantic~=1.10 - types-PyYAML - types-paramiko - types-requests diff --git a/anta/cli/utils.py b/anta/cli/utils.py index fe68bab0e..4b2cfdf7f 100644 --- a/anta/cli/utils.py +++ b/anta/cli/utils.py @@ -67,11 +67,11 @@ def parse_inventory(ctx: click.Context, param: Option, value: str) -> AntaInvent insecure=ctx.params["insecure"], ) logger.info(f"Inventory {value} loaded") - return inventory except Exception as exc: # pylint: disable=broad-exception-caught logger.critical(tb_to_str(exc)) ctx.fail(f"Unable to parse ANTA Inventory file '{value}': {exc_to_str(exc)}") - return None + + return inventory def parse_catalog(ctx: click.Context, param: Option, value: str) -> List[Tuple[Callable[..., TestResult], Dict[Any, Any]]]: @@ -82,14 +82,13 @@ def parse_catalog(ctx: click.Context, param: Option, value: str) -> List[Tuple[C try: with open(value, "r", encoding="UTF-8") as file: data = safe_load(file) - return anta.loader.parse_catalog(data) # TODO catch proper exception # pylint: disable-next=broad-exception-caught except Exception as exc: logger.critical(tb_to_str(exc)) ctx.fail(f"Unable to parse ANTA Tests Catalog file '{value}': {exc_to_str(exc)}") - return None + return anta.loader.parse_catalog(data) def setup_logging(ctx: click.Context, param: Option, value: str) -> str: @@ -99,11 +98,11 @@ def setup_logging(ctx: click.Context, param: Option, value: str) -> str: """ try: anta.loader.setup_logging(value) - return value except Exception as exc: # pylint: disable=broad-exception-caught logger.critical(tb_to_str(exc)) ctx.fail(f"Unable to set ANTA logging level '{value}': {exc_to_str(exc)}") - return None + + return value class EapiVersion(click.ParamType): diff --git a/pyproject.toml b/pyproject.toml index c37d50b5f..9b8b11e4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,7 +56,7 @@ dev = [ "black==23.3.0", "flake8==6.0.0", "isort==5.10.1", - "mypy~=1.2", + "mypy~=1.4", "mypy-extensions~=1.0", "pre-commit>=2.20.0", "pylint>=2.16.1",