Skip to content

Commit

Permalink
Switch to Ruff for formatting.
Browse files Browse the repository at this point in the history
Enable most tests in Ruff.
  • Loading branch information
kpfleming committed Feb 4, 2024
1 parent 2417861 commit ca864a2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
53 changes: 15 additions & 38 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
3 changes: 1 addition & 2 deletions src/plugins/modules/tsigkey.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/python
# SPDX-FileCopyrightText: 2021 Kevin P. Fleming <kevin@km6g.us>
# SPDX-License-Identifier: Apache-2.0
# -*- coding: utf-8 -*-
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/modules/zone.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/python
# SPDX-FileCopyrightText: 2021 Kevin P. Fleming <kevin@km6g.us>
# SPDX-License-Identifier: Apache-2.0
# -*- coding: utf-8 -*-
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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":
Expand Down
9 changes: 4 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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

Expand All @@ -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]
Expand Down

0 comments on commit ca864a2

Please sign in to comment.