Skip to content

Commit

Permalink
Merge branch 'main' into fix/transform
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Aug 16, 2023
2 parents b6e2aa4 + 566b036 commit b650f8c
Show file tree
Hide file tree
Showing 33 changed files with 95 additions and 78 deletions.
32 changes: 16 additions & 16 deletions .config/requirements-lock.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
#
# pip-compile --no-annotate --output-file=.config/requirements-lock.txt --resolver=backtracking --strip-extras --unsafe-package=resolvelib --unsafe-package=ruamel-yaml-clib pyproject.toml
# pip-compile --no-annotate --output-file=.config/requirements-lock.txt --strip-extras --unsafe-package=resolvelib --unsafe-package=ruamel-yaml-clib pyproject.toml
#
ansible-compat==4.1.2
ansible-core==2.15.1
ansible-compat==4.1.6
ansible-core==2.15.3
attrs==23.1.0
black==23.7.0
bracex==2.3.post1
certifi==2023.5.7
certifi==2023.7.22
cffi==1.15.1
charset-normalizer==3.2.0
click==8.1.5
cryptography==41.0.2
click==8.1.6
cryptography==41.0.3
filelock==3.12.2
idna==3.4
importlib-resources==5.0.7
jinja2==3.1.2
jsonschema==4.18.3
jsonschema-specifications==2023.6.1
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
markdown-it-py==3.0.0
markupsafe==2.1.3
mdurl==0.1.2
mypy-extensions==1.0.0
packaging==23.1
pathspec==0.11.1
platformdirs==3.9.1
pathspec==0.11.2
platformdirs==3.10.0
pycparser==2.21
pygments==2.15.1
pyyaml==6.0
referencing==0.29.1
pygments==2.16.1
pyyaml==6.0.1
referencing==0.30.2
requests==2.31.0
rich==13.4.2
rpds-py==0.8.10
rich==13.5.2
rpds-py==0.9.2
ruamel-yaml==0.17.32
subprocess-tee==0.4.1
tomli==2.0.1
typing-extensions==4.7.1
urllib3==2.0.3
urllib3==2.0.4
wcmatch==8.4.1
yamllint==1.32.0

Expand Down
40 changes: 20 additions & 20 deletions .config/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# pip-compile --extra=docs --extra=test --no-annotate --output-file=.config/requirements.txt --strip-extras --unsafe-package=resolvelib --unsafe-package=ruamel-yaml-clib pyproject.toml
#
ansible-compat==4.1.2
ansible-core==2.15.1
ansible-compat==4.1.6
ansible-core==2.15.3
astroid==2.15.6
attrs==23.1.0
beautifulsoup4==4.12.2
Expand All @@ -18,14 +18,14 @@ cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
colorama==0.4.6
coverage==7.2.7
coverage==7.3.0
coverage-enable-subprocess==1.0
cryptography==41.0.2
cryptography==41.0.3
csscompressor==0.9.5
cssselect2==0.7.0
defusedxml==0.7.1
dill==0.3.6
exceptiongroup==1.1.2
dill==0.3.7
exceptiongroup==1.1.3
execnet==2.0.2
filelock==3.12.2
ghp-import==2.1.0
Expand All @@ -40,8 +40,8 @@ isort==5.12.0
jinja2==3.1.2
jmespath==1.0.1
jsmin==3.0.1
jsonschema==4.18.3
jsonschema-specifications==2023.6.1
jsonschema==4.19.0
jsonschema-specifications==2023.7.1
lazy-object-proxy==1.9.0
markdown==3.3.7
markdown-exec==1.6.0
Expand All @@ -62,22 +62,22 @@ mkdocs-minify-plugin==0.6.4
mkdocs-monorepo-plugin==1.0.5
mkdocstrings==0.22.0
mkdocstrings-python==1.1.0
mypy==1.4.1
mypy==1.5.0
mypy-extensions==1.0.0
netaddr==0.8.0
packaging==23.1
pathspec==0.11.1
pathspec==0.11.2
pillow==9.5.0
pipdeptree==2.7.1
platformdirs==3.9.1
platformdirs==3.10.0
pluggy==1.2.0
ply==3.11
psutil==5.9.5
pycparser==2.21
pygments==2.15.1
pylint==2.17.4
pylint==2.17.5
pymdown-extensions==10.0.1
pyparsing==3.1.0
pyparsing==3.1.1
pytest==7.4.0
pytest-mock==3.11.1
pytest-plus==0.4.0
Expand All @@ -86,12 +86,12 @@ python-dateutil==2.8.2
python-slugify==8.0.1
pyyaml==6.0
pyyaml-env-tag==0.1
rdflib==6.3.2
referencing==0.29.1
rdflib==7.0.0
referencing==0.30.2
regex==2023.5.5
requests==2.31.0
rich==13.4.2
rpds-py==0.8.10
rich==13.5.2
rpds-py==0.9.2
ruamel-yaml==0.17.32
six==1.16.0
soupsieve==2.4.1
Expand All @@ -100,9 +100,9 @@ subprocess-tee==0.4.1
text-unidecode==1.3
tinycss2==1.2.1
tomli==2.0.1
tomlkit==0.11.8
types-jsonschema==4.17.0.9
types-pyyaml==6.0.12.10
tomlkit==0.12.1
types-jsonschema==4.17.0.10
types-pyyaml==6.0.12.11
typing-extensions==4.6.2
uritools==4.0.1
urllib3==2.0.2
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ updates:
- dependabot-deps-updates
- skip-changelog
versioning-strategy: lockfile-only
ignore:
- dependency-name: mypy
- dependency-name: pipdeptree
- dependency-name: pylint
- dependency-name: types-jsonschema
- dependency-name: types-pyyaml
- package-ecosystem: "github-actions"
directory: "/"
schedule:
Expand Down
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- id: check-useless-excludes
- repo: https://github.com/pre-commit/mirrors-prettier
# keep it before yamllint
rev: v3.0.1
rev: v3.0.2
hooks:
- id: prettier
# Temporary excludes so we can gradually normalize the formatting
Expand Down Expand Up @@ -63,14 +63,14 @@ repos:
- prettier-plugin-toml
- prettier-plugin-sort-json
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v6.31.1
rev: v7.0.0
hooks:
- id: cspell
# entry: codespell --relative
args: [--relative, --no-progress, --no-summary]
name: Spell check with cspell
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.3
rev: 0.24.1
hooks:
- id: check-github-workflows
- repo: https://github.com/pre-commit/pre-commit-hooks.git
Expand Down Expand Up @@ -130,7 +130,7 @@ repos:
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.282"
rev: "v0.0.284"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand All @@ -140,13 +140,13 @@ repos:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
rev: v1.5.0
hooks:
- id: mypy
# empty args needed in order to match mypy cli behavior
args: [--strict]
additional_dependencies:
- ansible-compat>=4.1.2
- ansible-compat>=4.1.6
- black>=22.10.0
- cryptography>=39.0.1
- filelock>=3.12.2
Expand All @@ -169,13 +169,13 @@ repos:
plugins/.*
)$
- repo: https://github.com/pycqa/pylint
rev: v3.0.0a6
rev: v3.0.0a7
hooks:
- id: pylint
args:
- --output-format=colorized
additional_dependencies:
- ansible-compat>=4.1.2
- ansible-compat>=4.1.6
- ansible-core>=2.14.0
- black>=22.10.0
- docutils
Expand All @@ -192,7 +192,7 @@ repos:
- wcmatch
- yamllint
- repo: https://github.com/jazzband/pip-tools
rev: 7.2.0
rev: 7.3.0
hooks:
- id: pip-compile
name: lock
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ python_files = [
xfail_strict = true

[tool.ruff]
required-version = "0.0.282"
required-version = "0.0.284"
ignore = [
"E501", # we use black
"ERA001", # auto-removal of commented out code affects development and vscode integration
Expand Down
13 changes: 10 additions & 3 deletions src/ansiblelint/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import logging
import os
from collections import defaultdict, namedtuple
from collections import defaultdict
from functools import partial
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, NamedTuple

import yaml
from yaml import YAMLError
Expand All @@ -19,7 +19,14 @@
if TYPE_CHECKING:
from pathlib import Path

IgnoreFile = namedtuple("IgnoreFile", "default alternative")

class IgnoreFile(NamedTuple):
"""IgnoreFile n."""

default: str
alternative: str


IGNORE_FILE = IgnoreFile(".ansible-lint-ignore", ".config/ansible-lint-ignore.txt")

yaml_load = partial(yaml.load, Loader=FullLoader)
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def all_subclasses(cls: type) -> set[type]:
class RulesCollection:
"""Container for a collection of rules."""

def __init__(
def __init__( # pylint: disable=too-many-arguments
self,
rulesdirs: list[str] | list[Path] | None = None,
options: Options | None = None,
Expand Down
4 changes: 2 additions & 2 deletions src/ansiblelint/rules/fqcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def test_fqcn_deep_fail() -> None:
"""Test rule matches."""
collection = RulesCollection()
collection.register(FQCNBuiltinsRule())
failure = "examples/collection/plugins/modules/deep/beta.py"
failure = "examples/.collection/plugins/modules/deep/beta.py"
results = Runner(failure, rules=collection).run()
assert len(results) == 1
assert results[0].tag == "fqcn[deep]"
Expand All @@ -279,6 +279,6 @@ def test_fqcn_deep_pass() -> None:
"""Test rule does not match."""
collection = RulesCollection()
collection.register(FQCNBuiltinsRule())
success = "examples/collection/plugins/modules/alpha.py"
success = "examples/.collection/plugins/modules/alpha.py"
results = Runner(success, rules=collection).run()
assert len(results) == 0
12 changes: 6 additions & 6 deletions src/ansiblelint/rules/galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_galaxy_collection_version_positive() -> None:
"""Positive test for collection version in galaxy."""
collection = RulesCollection()
collection.register(GalaxyRule())
success = "examples/collection/galaxy.yml"
success = "examples/.collection/galaxy.yml"
good_runner = Runner(success, rules=collection)
assert [] == good_runner.run()

Expand All @@ -203,7 +203,7 @@ def test_galaxy_no_collection_version() -> None:
"""Test for no collection version in galaxy."""
collection = RulesCollection()
collection.register(GalaxyRule())
failure = "examples/no_collection_version/galaxy.yml"
failure = "examples/.no_collection_version/galaxy.yml"
bad_runner = Runner(failure, rules=collection)
errs = bad_runner.run()
assert len(errs) == 1
Expand Down Expand Up @@ -236,25 +236,25 @@ def test_coerce() -> None:
id="pass",
),
pytest.param(
"examples/collection/galaxy.yml",
"examples/.collection/galaxy.yml",
["schema[galaxy]"],
id="schema",
),
pytest.param(
"examples/invalid_dependencies/galaxy.yml",
"examples/.invalid_dependencies/galaxy.yml",
[
"galaxy[invalid-dependency-version]",
"galaxy[invalid-dependency-version]",
],
id="invalid-dependency-version",
),
pytest.param(
"examples/no_changelog/galaxy.yml",
"examples/.no_changelog/galaxy.yml",
["galaxy[no-changelog]"],
id="no-changelog",
),
pytest.param(
"examples/no_collection_version/galaxy.yml",
"examples/.no_collection_version/galaxy.yml",
["schema[galaxy]", "galaxy[version-missing]"],
id="no-collection-version",
),
Expand Down
12 changes: 9 additions & 3 deletions src/ansiblelint/rules/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import logging
import re
import sys
from collections import namedtuple
from pathlib import Path
from typing import TYPE_CHECKING, Any
from typing import TYPE_CHECKING, Any, NamedTuple

import black
import jinja2
Expand All @@ -30,7 +29,14 @@
_logger = logging.getLogger(__package__)
KEYWORDS_WITH_IMPLICIT_TEMPLATE = ("changed_when", "failed_when", "until", "when")

Token = namedtuple("Token", "lineno token_type value")

class Token(NamedTuple):
"""Token."""

lineno: int
token_type: str
value: str


ignored_re = re.compile(
"|".join( # noqa: FLY002
Expand Down
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def matchyaml(self, file: Lintable) -> list[MatchError]:
("file", "expected_kind", "expected"),
(
pytest.param(
"examples/collection/galaxy.yml",
"examples/.collection/galaxy.yml",
"galaxy",
["'GPL' is not one of"],
id="galaxy",
Expand Down
Loading

0 comments on commit b650f8c

Please sign in to comment.