diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a79d7d..1f2172b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,6 +2,6 @@ --- repos: - repo: https://github.com/tox-dev/pyproject-fmt - rev: "0.9.2" + rev: "1.7.0" hooks: - id: pyproject-fmt diff --git a/pyproject.toml b/pyproject.toml index ed11725..c09e700 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,45 +1,22 @@ -[tool.black] -line-length = 100 -target-version = ['py38'] -exclude = ''' -/( - \.eggs - | \.git - | \.venv - | \venv - | _build - | build - | dist - | .tox -)/ -''' - [tool.ruff] src = ["src"] -output-format = "grouped" target-version = "py38" line-length = 100 -select = [ - "A", - "B", -# "C", - "COM", - "DTZ", - "E", - "F", - "I", - "ISC", - "N", - "PT", - "Q", - "RET", - "RUF", - "SIM", - "UP", - "W292", - "YTT", -] + +[tool.ruff.lint] +select = ["ALL"] ignore = [ - "RUF012", + "ANN", # Mypy is better at this. + "COM812", # conflicts with formatter + "C901", # Leave complexity to me. + "D", # We have different ideas about docstrings. + "INP001", # we don't care that these are in implicit namespace packages + "ISC001", # conflicts with formatter + "PLR0912", # Leave complexity to me. + "PLR0915", # Leave complexity to me. + "PLW0603", # globals are used intentionally here + "RUF012", # no need for this warning in Ansible modules + "S101", # assert + "TRY301", # Raise in try blocks can totally make sense. ] unfixable = ["F401"] diff --git a/src/plugins/modules/tsigkey.py b/src/plugins/modules/tsigkey.py index c6f6415..648602e 100644 --- a/src/plugins/modules/tsigkey.py +++ b/src/plugins/modules/tsigkey.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # SPDX-FileCopyrightText: 2021 Kevin P. Fleming # SPDX-License-Identifier: Apache-2.0 # -*- coding: utf-8 -*- @@ -319,7 +318,7 @@ def main(): partial_key_info = [k for k in api_client.tsigkey.listTSIGKeys() if k["name"] == key] if len(partial_key_info) == 0: - if (state == "exists") or (state == "absent"): + if state in ("exists", "absent"): # exit as there is nothing left to do module.exit_json(**result) else: diff --git a/src/plugins/modules/zone.py b/src/plugins/modules/zone.py index a662970..79452e6 100644 --- a/src/plugins/modules/zone.py +++ b/src/plugins/modules/zone.py @@ -1,4 +1,3 @@ -#!/usr/bin/python # SPDX-FileCopyrightText: 2021 Kevin P. Fleming # SPDX-License-Identifier: Apache-2.0 # -*- coding: utf-8 -*- @@ -796,7 +795,7 @@ class MetadataBinaryPresence(Metadata): def default(self): return False - def user_meta_from_api(self, user_meta, api_meta_item): + def user_meta_from_api(self, user_meta, _api_meta_item): user_meta[self.meta] = True def set(self, value, api_client): @@ -1411,7 +1410,7 @@ def main(): partial_zone_info = api_client.zones.listZones(zone=zone) if len(partial_zone_info) == 0: - if (state == "exists") or (state == "absent"): + if state in ("exists", "absent"): # exit as there is nothing left to do module.exit_json(**result) elif state == "notify": diff --git a/tox.ini b/tox.ini index b9f1c25..134f8ce 100644 --- a/tox.ini +++ b/tox.ini @@ -17,8 +17,7 @@ commands= [lint-base] deps= {[galaxy-setup]deps} - black>=23 - ruff>=0.0.237 + ruff>=0.2.0 ansible-lint antsibull-docs setenv= @@ -45,7 +44,7 @@ commands_pre= {[lint-base]commands_pre} {[lint-base]commands} commands= - black --check --diff --preview src + ruff format --check --diff src ruff check --output-format=github src ansible-lint --strict --profile production -v @@ -60,8 +59,8 @@ commands_pre= {[lint-base]commands_pre} {[lint-base]commands} commands= - black --preview src - ruff check --fix src + ruff format src + ruff check --output-format=full --fix --show-fixes src ansible-lint --fix all --strict --profile production -v [testenv:py{38,39,310,311,312}-ci-action]