From c9fd91075fe91c7c6bbbe7712601eefc89549676 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Wed, 25 Oct 2023 14:48:41 +0100 Subject: [PATCH] Update linters (#3870) --- .pre-commit-config.yaml | 10 +++++----- pyproject.toml | 2 +- src/ansiblelint/schemas/__main__.py | 5 ++++- src/ansiblelint/utils.py | 6 +++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 85ebc8a6e5..d977ef33ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -64,7 +64,7 @@ repos: - prettier-plugin-toml - prettier-plugin-sort-json - repo: https://github.com/streetsidesoftware/cspell-cli - rev: v7.3.1 + rev: v7.3.2 hooks: - id: cspell # entry: codespell --relative @@ -75,7 +75,7 @@ repos: hooks: - id: check-github-workflows - repo: https://github.com/pre-commit/pre-commit-hooks.git - rev: v4.4.0 + rev: v4.5.0 hooks: - id: end-of-file-fixer # ignore formatting-prettier to have an accurate prettier comparison @@ -131,17 +131,17 @@ repos: types: [file, yaml] entry: yamllint --strict - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.0.292" + rev: "v0.1.2" hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - repo: https://github.com/psf/black - rev: 23.9.1 + rev: 23.10.1 hooks: - id: black language_version: python3 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.5.1 + rev: v1.6.1 hooks: - id: mypy # empty args needed in order to match mypy cli behavior diff --git a/pyproject.toml b/pyproject.toml index 94d773af3f..f0f7905743 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -232,7 +232,7 @@ python_files = [ xfail_strict = true [tool.ruff] -required-version = "0.0.292" +required-version = "0.1.2" ignore = [ "D203", # incompatible with D211 "D213", # incompatible with D212 diff --git a/src/ansiblelint/schemas/__main__.py b/src/ansiblelint/schemas/__main__.py index bc0d80cf42..41bdd41ab7 100644 --- a/src/ansiblelint/schemas/__main__.py +++ b/src/ansiblelint/schemas/__main__.py @@ -68,7 +68,10 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int: raise RuntimeError(msg) path = Path(__file__).parent.resolve() / f"{kind}.json" _logger.debug("Refreshing %s schema ...", kind) - request = Request(url) + if not url.startswith(("http:", "https:")): + msg = f"Unexpected url schema: {url}" + raise ValueError(msg) + request = Request(url) # noqa: S310 etag = data.get("etag", "") if etag: request.add_header("If-None-Match", f'"{data.get("etag")}"') diff --git a/src/ansiblelint/utils.py b/src/ansiblelint/utils.py index 5972abc855..03eaf84614 100644 --- a/src/ansiblelint/utils.py +++ b/src/ansiblelint/utils.py @@ -702,7 +702,11 @@ class Task(dict[str, Any]): @property def name(self) -> str | None: """Return the name of the task.""" - return self.raw_task.get("name", None) + name = self.raw_task.get("name", None) + if name is not None and not isinstance(name, str): + msg = "Task name can only be a string." + raise RuntimeError(msg) + return name @property def action(self) -> str: