Skip to content

Commit 3e265ff

Browse files
authored
Minor build fixes (#386)
1 parent 5a92cfc commit 3e265ff

File tree

8 files changed

+45
-24
lines changed

8 files changed

+45
-24
lines changed

.config/pydoclint-baseline.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tests/conftest.py
2+
DOC503: Method `Infrastructure.__post_init__` exceptions in the "Raises" section in the docstring do not match those in the function body Raises values in the docstring: ['ValueError', 'ValueError', 'ValueError']. Raised exceptions in the body: ['ValueError'].
3+
--------------------

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,5 @@ cython_debug/
175175
_readthedocs
176176

177177
# ansible-builder
178-
context
179-
collections
178+
/context
179+
/collections

.pre-commit-config.yaml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,31 @@ repos:
4343
- prettier-plugin-toml
4444
- prettier-plugin-sort-json
4545

46-
- repo: https://github.com/psf/black
47-
rev: 24.8.0
48-
hooks:
49-
- id: black
50-
5146
- repo: https://github.com/pappasam/toml-sort
5247
rev: v0.23.1
5348
hooks:
5449
- id: toml-sort-fix
5550

5651
- repo: https://github.com/tox-dev/tox-ini-fmt
57-
rev: 1.3.1
52+
rev: 1.4.1
5853
hooks:
5954
- id: tox-ini-fmt
6055

6156
- repo: https://github.com/astral-sh/ruff-pre-commit
62-
rev: v0.6.3
57+
rev: v0.6.8
6358
hooks:
6459
- id: ruff
6560
args:
61+
- --fix
6662
- --exit-non-zero-on-fix
63+
types_or: [python, pyi]
64+
- id: ruff-format # must be after ruff
65+
types_or: [python, pyi]
66+
67+
- repo: https://github.com/psf/black # must be after ruff
68+
rev: 24.8.0
69+
hooks:
70+
- id: black
6771

6872
- repo: https://github.com/streetsidesoftware/cspell-cli
6973
rev: v8.13.3
@@ -72,15 +76,15 @@ repos:
7276
name: Spell check with cspell
7377

7478
- repo: https://github.com/jsh9/pydoclint
75-
rev: "0.5.6"
79+
rev: "0.5.8"
7680
hooks:
7781
- id: pydoclint
7882
# This allows automatic reduction of the baseline file when needed.
7983
entry: sh -ec "pydoclint . && pydoclint --generate-baseline=1 ."
8084
pass_filenames: false
8185

8286
- repo: https://github.com/pycqa/pylint.git
83-
rev: v3.2.7
87+
rev: v3.3.1
8488
hooks:
8589
- id: pylint
8690
args:

bindep.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python3-devel
1+
python3-devel [platform:redhat]

pyproject.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ homepage = "https://github.com/ansible/ansible-dev-tools"
4141
repository = "https://github.com/ansible/ansible-dev-tools"
4242

4343
[tool.black]
44+
enable-unstable-feature = ["string_processing"]
4445
line-length = 100
46+
preview = true
4547

4648
[tool.coverage.report]
4749
exclude_also = ["if TYPE_CHECKING:", "pragma: no cover"]
@@ -336,6 +338,14 @@ line-length = 100
336338
target-version = "py310"
337339

338340
[tool.ruff.lint]
341+
external = [
342+
"DOC" # pydoclint
343+
]
344+
ignore = [
345+
# incompatible with ruff formatter
346+
"COM812", # missing-space-after-comma
347+
"ISC001" # implicit-str-concat
348+
]
339349
select = ["ALL"]
340350

341351
[tool.ruff.lint.flake8-pytest-style]

tests/conftest.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<...>
1717
Tracing '/**/src/<package>/__init__.py'
1818
"""
19+
1920
from __future__ import annotations
2021

2122
import errno
@@ -315,12 +316,7 @@ def _start_container() -> None:
315316
try:
316317
subprocess.run(cmd, check=True, capture_output=True, shell=True, text=True)
317318
except subprocess.CalledProcessError as exc:
318-
err = (
319-
f"Failed to start container:\n"
320-
f"cmd: {cmd}\n"
321-
f"stdout: {exc.stdout}\n"
322-
f"stderr: {exc.stderr}"
323-
)
319+
err = f"Failed to start container:\ncmd: {cmd}\nstdout: {exc.stdout}\nstderr: {exc.stderr}"
324320
pytest.fail(err)
325321

326322
# image is local, can't be pulled, use default
@@ -419,17 +415,24 @@ def _start_server() -> None:
419415
env=os.environ,
420416
)
421417
tries = 0
422-
max_tries = 10
418+
timeout = 2
419+
max_tries = 15 # GHA macos runner showed occasional failures with 10s
420+
msg = "Could not start the server."
423421
while tries < max_tries:
424422
try:
425-
res = requests.get("http://localhost:8000", timeout=1)
423+
# timeout increased to 2s due to observed GHA macos failures
424+
res = requests.get("http://localhost:8000", timeout=timeout)
426425
if res.status_code == requests.codes.get("not_found"):
427426
return
428-
except requests.exceptions.ConnectionError: # noqa: PERF203
427+
except (requests.exceptions.ConnectionError, requests.RequestException): # noqa: PERF203
429428
tries += 1
430429
time.sleep(1)
431-
432-
msg = "Could not start the server."
430+
INFRASTRUCTURE.proc.terminate()
431+
stdout, stderr = INFRASTRUCTURE.proc.communicate()
432+
msg += (
433+
f"Could not start the server after {tries} tries with a timeout of {timeout} seconds each."
434+
f" Server stdout:\n{stdout.decode()}\nServer stderr:\n{stderr.decode()}"
435+
)
433436
raise RuntimeError(msg)
434437

435438

tests/integration/test_container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def test_nav_playbook(
252252
assert any(output in line for line in stdout)
253253
cmd = (
254254
f"cd {tmp_path} &&"
255-
f" ansible-navigator run site.yml"
255+
" ansible-navigator run site.yml"
256256
f" --pp never --eei {infrastructure.navigator_ee}"
257257
)
258258
stdout = container_tmux.send_and_wait(cmd=cmd, wait_for="Successful", timeout=10)

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tox]
22
requires =
33
tox>=4.11.3
4+
tox-extra>=2.0.1
45
env_list =
56
py
67
deps

0 commit comments

Comments
 (0)