Skip to content

Commit

Permalink
Update linters (#3870)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Oct 25, 2023
1 parent 824d58f commit c9fd910
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/ansiblelint/schemas/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")}"')
Expand Down
6 changes: 5 additions & 1 deletion src/ansiblelint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c9fd910

Please sign in to comment.