Skip to content

Commit

Permalink
Enable toml sort (ansible#3969)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Jan 3, 2024
1 parent aa9788d commit 7b2f701
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 41 deletions.
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ repos:
- repo: meta
hooks:
- id: check-useless-excludes
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/mirrors-prettier
# keep it before yamllint
rev: v4.0.0-alpha.8
Expand Down Expand Up @@ -64,7 +68,7 @@ repos:
- prettier-plugin-toml
- prettier-plugin-sort-json
- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.2.1
rev: v8.3.0
hooks:
- id: cspell
# entry: codespell --relative
Expand Down Expand Up @@ -131,7 +135,7 @@ repos:
types: [file, yaml]
entry: yamllint --strict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.9"
rev: "v0.1.11"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
76 changes: 37 additions & 39 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[build-system]
requires = [
"setuptools >= 65.3.0", # required by pyproject+setuptools_scm integration and editable installs
"setuptools_scm[toml] >= 7.0.5", # required for "no-local-version" scheme

"setuptools_scm[toml] >= 7.0.5" # required for "no-local-version" scheme
]
build-backend = "setuptools.build_meta"

Expand All @@ -13,9 +12,9 @@ dynamic = ["version", "dependencies", "optional-dependencies"]
name = "ansible-lint"
description = "Checks playbooks for practices and behavior that could potentially be improved"
readme = "README.md"
authors = [{ "name" = "Will Thames", "email" = "[email protected]" }]
maintainers = [{ "name" = "Ansible by Red Hat", "email" = "[email protected]" }]
license = { text = "GPLv3+" }
authors = [{"name" = "Will Thames", "email" = "[email protected]"}]
maintainers = [{"name" = "Ansible by Red Hat", "email" = "[email protected]"}]
license = {text = "GPLv3+"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
Expand All @@ -36,19 +35,19 @@ classifiers = [
"Topic :: System :: Systems Administration",
"Topic :: Software Development :: Quality Assurance",
"Topic :: Software Development :: Testing",
"Topic :: Utilities",
"Topic :: Utilities"
]
keywords = ["ansible", "lint"]

[project.scripts]
ansible-lint = "ansiblelint.__main__:_run_cli_entrypoint"

[project.urls]
homepage = "https://github.com/ansible/ansible-lint"
documentation = "https://ansible.readthedocs.io/projects/lint/"
repository = "https://github.com/ansible/ansible-lint"
changelog = "https://github.com/ansible/ansible-lint/releases"

[project.scripts]
ansible-lint = "ansiblelint.__main__:_run_cli_entrypoint"

[tool.black]
target-version = ["py39"]

Expand All @@ -57,14 +56,6 @@ skip = ".tox,.mypy_cache,build,.git,.eggs,pip-wheel-metadata"
# indention is a typo in ruamel.yaml's API
ignore-words-list = "indention"

[tool.coverage.run]
source = ["src"]
# Do not use branch until bug is fixes:
# https://github.com/nedbat/coveragepy/issues/605
# branch = true
parallel = true
concurrency = ["multiprocessing", "thread"]

# Keep this default because xml/report do not know to use load it from config file:
# data_file = ".coverage"
[tool.coverage.paths]
Expand All @@ -81,6 +72,14 @@ skip_empty = true
ignore_errors = true
show_missing = true

[tool.coverage.run]
source = ["src"]
# Do not use branch until bug is fixes:
# https://github.com/nedbat/coveragepy/issues/605
# branch = true
parallel = true
concurrency = ["multiprocessing", "thread"]

[tool.isort]
profile = "black"
# add_imports = "from __future__ import annotations"
Expand Down Expand Up @@ -117,23 +116,22 @@ module = [
"ansiblelint._version", # generated
"license_expression",
"ruamel.yaml",
"yamllint.*",
"yamllint.*"
]
ignore_missing_imports = true
ignore_errors = true

[tool.pylint.MAIN]
extension-pkg-allow-list = ["black.parsing"]

[tool.pylint.IMPORTS]
preferred-modules = ["py:pathlib", "unittest:pytest"]

[tool.pylint.MAIN]
extension-pkg-allow-list = ["black.parsing"]

[tool.pylint.MASTER]
bad-names = [
# spell-checker:ignore linenumber
"linenumber", # use lineno instead
"line_number", # use lineno instead

"line_number" # use lineno instead
]
# pylint defaults + f,fh,v,id
good-names = ["i", "j", "k", "Run", "_", "f", "fh", "v", "id", "T"]
Expand All @@ -154,10 +152,10 @@ disable = [
# https://github.com/PyCQA/pylint/issues/850
"cyclic-import",
# https://github.com/PyCQA/pylint/issues/8453
"preferred-module",
"preferred-module"
]
enable = [
"useless-suppression", # Identify unneeded pylint disable statements
"useless-suppression" # Identify unneeded pylint disable statements
]

[tool.pylint.REPORTING]
Expand Down Expand Up @@ -196,7 +194,7 @@ filterwarnings = [
# https://github.com/ansible/ansible/issues/81906
"ignore:'importlib.abc.TraversableResources' is deprecated and slated for removal in Python 3.14:DeprecationWarning",
# https://github.com/ansible/ansible/pull/80968
"ignore:Attribute s is deprecated and will be removed in Python 3.14; use value instead:DeprecationWarning",
"ignore:Attribute s is deprecated and will be removed in Python 3.14; use value instead:DeprecationWarning"
]
junit_duration_report = "call"
# Our github annotation parser from .github/workflows/tox.yml requires xunit1 format. Ref:
Expand All @@ -217,15 +215,15 @@ norecursedirs = [
"collections",
"dist",
"docs",
"src/ansible_lint.egg-info",
"src/ansible_lint.egg-info"
]
python_files = [
"test_*.py",
# Ref: https://docs.pytest.org/en/latest/reference.html#confval-python_files
# Needed to discover legacy nose test modules:
"Test*.py",
# Needed to discover embedded Rule tests
"rules/*.py",
"rules/*.py"
]
# Using --pyargs instead of testpath as we embed some tests
# See: https://github.com/pytest-dev/pytest/issues/6451#issuecomment-687043537
Expand All @@ -251,17 +249,13 @@ ignore = [
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
"TRY",
"PERF203",
"PD011", # We are not using pandas, any .values attributes are unrelated
"PD011" # We are not using pandas, any .values attributes are unrelated
]
select = ["ALL"]
target-version = "py39"
# Same as Black.
line-length = 88

[tool.ruff.mccabe]
# Implicit 10 is too low for our codebase, even black uses 18 as default.
max-complexity = 20

[tool.ruff.flake8-builtins]
builtins-ignorelist = ["id"]

Expand All @@ -271,20 +265,24 @@ parametrize-values-type = "tuple"
[tool.ruff.isort]
known-first-party = ["ansiblelint"]

[tool.ruff.mccabe]
# Implicit 10 is too low for our codebase, even black uses 18 as default.
max-complexity = 20

[tool.ruff.per-file-ignores]
"test/**/*.py" = ["S"]
"src/ansiblelint/rules/*.py" = ["S"]
"src/ansiblelint/testing/*.py" = ["S"]
# Temporary disabled until we fix them:
"src/ansiblelint/{utils,file_utils,runner,loaders,constants,config,cli,_mockings}.py" = [
"PTH",
"PTH"
]

[tool.setuptools.dynamic]
optional-dependencies.docs = { file = [".config/docs-requirements.txt"] }
optional-dependencies.test = { file = [".config/test-requirements.txt"] }
optional-dependencies.lock = { file = [".config/lock-requirements.txt"] }
dependencies = { file = [".config/runtime-requirements.txt"] }
dependencies = {file = [".config/runtime-requirements.txt"]}
optional-dependencies.docs = {file = [".config/docs-requirements.txt"]}
optional-dependencies.test = {file = [".config/test-requirements.txt"]}
optional-dependencies.lock = {file = [".config/lock-requirements.txt"]}

[tool.setuptools_scm]
local_scheme = "no-local-version"
Expand All @@ -298,5 +296,5 @@ git_describe_command = [
"--tags",
"--long",
"--match",
"v*.*",
"v*.*"
]

0 comments on commit 7b2f701

Please sign in to comment.