Skip to content

Commit

Permalink
Merge branch 'main' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
cidrblock authored Jul 30, 2024
2 parents 0cb0cac + 9d2f006 commit 85bee40
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 69 deletions.
48 changes: 24 additions & 24 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
# pip-compile --all-extras --no-annotate --output-file=.config/constraints.txt --strip-extras .config/requirements.in pyproject.toml
#
ansible-builder==3.1.0
astroid==3.2.2
astroid==3.2.4
attrs==23.2.0
babel==2.15.0
beautifulsoup4==4.12.3
bindep==2.11.0
black==24.4.2
build==1.2.1
cachetools==5.3.3
cachetools==5.4.0
cairocffi==1.7.1
cairosvg==2.7.1
certifi==2024.6.2
certifi==2024.7.4
cffi==1.16.0
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
coverage==7.5.4
coverage==7.6.0
csscompressor==0.9.5
cssselect2==0.7.0
defusedxml==0.7.1
Expand All @@ -31,19 +31,19 @@ distlib==0.3.8
distro==1.9.0
dnspython==2.6.1
docstring-parser-fork==0.0.9
exceptiongroup==1.2.1
exceptiongroup==1.2.2
execnet==2.1.1
filelock==3.15.4
ghp-import==2.1.0
griffe==0.47.0
griffe==0.48.0
htmlmin2==0.1.13
identify==2.5.36
identify==2.6.0
idna==3.7
iniconfig==2.0.0
isort==5.13.2
jinja2==3.1.4
jsmin==3.0.1
jsonschema==4.22.0
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
linkchecker==10.4.0
markdown==3.6
Expand All @@ -59,44 +59,44 @@ mkdocs-gen-files==0.5.0
mkdocs-get-deps==0.2.0
mkdocs-htmlproofer-plugin==1.2.1
mkdocs-macros-plugin==1.0.5
mkdocs-material==9.5.27
mkdocs-material==9.5.30
mkdocs-material-extensions==1.3.1
mkdocs-minify-plugin==0.8.0
mkdocs-monorepo-plugin==1.1.0
mkdocstrings==0.25.1
mkdocstrings-python==1.10.5
mypy==1.10.1
mkdocstrings==0.25.2
mkdocstrings-python==1.10.7
mypy==1.11.0
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging==24.1
paginate==0.5.6
parsley==1.3
pathspec==0.12.1
pbr==6.0.0
pillow==10.3.0
pillow==10.4.0
pip-tools==7.4.1
pipdeptree==2.23.0
pipdeptree==2.23.1
platformdirs==4.2.2
pluggy==1.5.0
pre-commit==3.7.1
pycparser==2.22
pydoclint==0.5.3
pydoclint==0.5.6
pygments==2.18.0
pylint==3.2.5
pymdown-extensions==10.8.1
pylint==3.2.6
pymdown-extensions==10.9
pyproject-api==1.7.1
pyproject-hooks==1.1.0
pytest==8.2.2
pytest==8.3.2
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-slugify==8.0.4
pyyaml==6.0.1
pyyaml-env-tag==0.1
referencing==0.35.1
regex==2024.5.15
regex==2024.7.24
requests==2.32.3
rpds-py==0.18.1
ruff==0.5.0
rpds-py==0.19.1
ruff==0.5.5
six==1.16.0
soupsieve==2.5
subprocess-tee==0.4.2
Expand All @@ -105,9 +105,9 @@ text-unidecode==1.3
tinycss2==1.3.0
toml-sort==0.23.1
tomli==2.0.1
tomlkit==0.12.5
tox==4.15.1
types-pyyaml==6.0.12.20240311
tomlkit==0.13.0
tox==4.16.0
types-pyyaml==6.0.12.20240724
typing-extensions==4.12.2
urllib3==2.2.2
virtualenv==20.26.3
Expand Down
11 changes: 2 additions & 9 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
argnames
argvalues
bindep
bindir
bthornto
caplog
capsys
cauthor
cdescription
cnamespace
cpart
cpath
crepository
csource
delenv
excinfo
fileh
fqcn
jsonschema
levelname
levelno
netcommon
oidc
purelib
reqs
setenv
specp
treemaker
uninstallation
usefixtures
vuuid
xmltodict
28 changes: 16 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
---
# cspell:ignore mislav
name: release

"on":
on:
release:
types: [published]
workflow_dispatch:

jobs:
pypi:
name: Publish to PyPI registry
release:
environment: release
runs-on: ubuntu-22.04
permissions:
Expand All @@ -18,13 +15,12 @@ jobs:
env:
FORCE_COLOR: 1
PY_COLORS: 1
TOXENV: pkg

steps:
- name: Switch to using Python 3.10 by default
- name: Switch to using Python 3.12 by default
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.12"

- name: Install tox
run: python3 -m pip install --user "tox>=4.0.0"
Expand All @@ -33,12 +29,20 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed by setuptools-scm
submodules: true

- name: Build dists
run: python -m tox
run: python3 -m tox -e pkg

- name: Publish to pypi.org
if: >- # "create" workflows run separately from "push" & "pull_request"
github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@release/v1

forum_post:
needs: release
runs-on: ubuntu-22.04

steps:
- name: Retreive the forum post script from team-devtools
run: curl -O https://raw.githubusercontent.com/ansible/team-devtools/main/.github/workflows/forum_post.py

- name: Run the forum post script
run: python3 forum_post.py ${{ github.event.repository.full_name }} ${{ github.event.release.tag_name }} ${{ secrets.FORUM_KEY }} ${{ secrets.FORUM_USER }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ repos:
- id: tox-ini-fmt

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.0
rev: v0.5.5
hooks:
- id: ruff
args:
Expand Down
3 changes: 3 additions & 0 deletions .sonarcloud.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sonar.python.version=3.10, 3.11, 3.12, 3.13
sonar.sources=src/
sonar.tests=tests/
1 change: 1 addition & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.python",
"sonarsource.sonarlint-vscode",
"streetsidesoftware.code-spell-checker"
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,9 @@
"python.testing.unittestEnabled": false,
"triggerTaskOnSave.tasks": {
"pydoclint": ["*.py"]
},
"sonarlint.connectedMode.project": {
"connectionId": "ansible",
"projectKey": "ansible_ansible-dev-environment"
}
}
1 change: 1 addition & 0 deletions src/ansible_dev_environment/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def parse_collection_request( # noqa: PLR0915
output.debug(msg)
collection.path = path
msg = f"Setting collection path: {collection.path}"
output.debug(msg)
collection.opt_deps = string.split("[")[1].split("]")[0]
msg = f"Setting optional dependencies: {collection.opt_deps}"
output.debug(msg)
Expand Down
9 changes: 4 additions & 5 deletions src/ansible_dev_environment/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@
from dataclasses import dataclass
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, TypeVar
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from .utils import TermFeatures


T = TypeVar("T", bound="Level")
GOLDEN_RATIO = 1.61803398875


Expand Down Expand Up @@ -109,7 +108,7 @@ def log_level(self: Level) -> int:
return mapping[self]

@classmethod
def _longest_name(cls: type[T]) -> int:
def _longest_name(cls) -> int:
"""Return the longest exit message prefix.
Returns:
Expand All @@ -118,7 +117,7 @@ def _longest_name(cls: type[T]) -> int:
return max(len(member.value) for member in cls)

@classmethod
def longest_formatted(cls: type[T]) -> int:
def longest_formatted(cls) -> int:
"""Return the longest exit message prefix.
Returns:
Expand Down Expand Up @@ -213,7 +212,7 @@ def to_lines(
class Output:
"""Output functionality."""

def __init__( # noqa: PLR0913
def __init__(
self: Output,
log_file: str,
log_level: str,
Expand Down
14 changes: 10 additions & 4 deletions src/ansible_dev_environment/subcommands/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@


class Installer:
"""The installer class."""
"""The installer class.
Attributes:
RE_GALAXY_INSTALLED: The regular expression to match galaxy installed collections
"""

RE_GALAXY_INSTALLED = re.compile(r"(\w+\.\w+):.*installed")

def __init__(self: Installer, config: Config, output: Output) -> None:
"""Initialize the installer.
Expand Down Expand Up @@ -180,7 +186,7 @@ def _install_galaxy_collections(
err = f"Failed to install collection: {exc}\n{exc.stderr}"
self._output.critical(err)
return
installed = re.findall(r"(\w+\.\w+):.*installed", proc.stdout)
installed = self.RE_GALAXY_INSTALLED.findall(proc.stdout)
msg = f"Installed collections include: {oxford_join(installed)}"
self._output.note(msg)

Expand Down Expand Up @@ -231,7 +237,7 @@ def _install_galaxy_requirements(self: Installer) -> None:
err = f"Failed to install collections: {exc} {exc.stderr}"
self._output.critical(err)

installed = re.findall(r"(\w+\.\w+):.*installed", proc.stdout)
installed = self.RE_GALAXY_INSTALLED.findall(proc.stdout)
if not self._config.args.cpi:
msg = f"Installed collections include: {oxford_join(installed)}"
else:
Expand Down Expand Up @@ -472,7 +478,7 @@ def _install_local_collection(
collection.cache_dir / "MANIFEST.json",
)

installed = re.findall(r"(\w+\.\w+):.*installed", proc.stdout)
installed = self.RE_GALAXY_INSTALLED.findall(proc.stdout)
msg = f"Installed collections include: {oxford_join(installed)}"
self._output.note(msg)

Expand Down
14 changes: 6 additions & 8 deletions src/ansible_dev_environment/subcommands/treemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
ScalarVal = bool | str | float | int | None
JSONVal = ScalarVal | list["JSONVal"] | dict[str, "JSONVal"]

NOT_A_DICT = "Tree dict is not a dict."


class TreeMaker:
"""Generate a dependency tree."""
Expand Down Expand Up @@ -99,14 +101,12 @@ def run(self: TreeMaker) -> None: # noqa: C901, PLR0912, PLR0915
else:
pruned_tree_dict: JSONVal = {}
if not isinstance(pruned_tree_dict, dict):
msg = "Tree dict is not a dict."
raise TypeError(msg)
raise TypeError(NOT_A_DICT)
for collection_name in list(tree_dict.keys()):
found = False
for value in tree_dict.values():
if not isinstance(value, dict):
msg = "Tree dict is not a dict."
raise TypeError(msg)
raise TypeError(NOT_A_DICT)
if collection_name in value:
found = True
if not found:
Expand Down Expand Up @@ -141,12 +141,10 @@ def add_python_reqs(
TypeError: If the tree dict is not a dict.
"""
if not isinstance(tree_dict, dict):
msg = "Tree dict is not a dict."
raise TypeError(msg)
raise TypeError(NOT_A_DICT)
collection = tree_dict[collection_name]
if not isinstance(collection, dict):
msg = "Tree dict is not a dict."
raise TypeError(msg)
raise TypeError(NOT_A_DICT)
collection["python requirements"] = []

for dep in sorted(python_deps):
Expand Down
2 changes: 1 addition & 1 deletion src/ansible_dev_environment/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def is_scalar(obj: JSONVal) -> bool:
"""
return isinstance(obj, str | int | float | bool) or obj is None

def _print_tree( # noqa: C901, PLR0913, PLR0912
def _print_tree( # noqa: C901, PLR0912
self: Tree,
obj: JSONVal,
is_last: bool, # noqa: FBT001
Expand Down
Loading

0 comments on commit 85bee40

Please sign in to comment.