Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update linters #3870

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines +706 to +708
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this / what uncovered this issue? Did someone run into an issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cognifloyd Issue was reported by mypy, and it makes sense as someone might put some junk data into name. I did not reproduce it, but what mypy reported made sense.

return name

@property
def action(self) -> str:
Expand Down