From de791e785aaea738627e86d1e448a439b543b64d Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 11 Dec 2025 13:11:09 +0000 Subject: [PATCH] Migrate to pyproject.toml and ruff We also bump the pre-commit versions used. Change-Id: I0662b6cc7efd58e9fcf6e936dc5556fcc8492ddf Signed-off-by: Stephen Finucane --- .pre-commit-config.yaml | 20 +++++++++---------- pyproject.toml | 40 +++++++++++++++++++++++++++++++++++++ setup.cfg | 21 ------------------- tests/check_osc_commands.py | 2 +- 4 files changed, 50 insertions(+), 33 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f939028..b0f5197 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,30 +1,28 @@ --- -default_language_version: - # force all unspecified python hooks to run python3 - python: python3 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: v6.0.0 hooks: - id: trailing-whitespace - id: mixed-line-ending args: ['--fix', 'lf'] exclude: '.*\.(svg)$' - - id: check-byte-order-marker + - id: fix-byte-order-marker - id: check-executables-have-shebangs - id: check-merge-conflict - id: debug-statements - id: check-yaml files: .*\.(yaml|yml)$ args: ['--unsafe'] - - repo: https://github.com/psf/black - rev: 23.12.1 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.8 hooks: - - id: black - args: ['-S', '-l', '79'] + - id: ruff-check + args: ['--fix', '--unsafe-fixes'] + - id: ruff-format - repo: https://opendev.org/openstack/hacking - rev: 6.1.0 + rev: 8.0.0 hooks: - id: hacking additional_dependencies: [] - exclude: '^(doc|releasenotes|tools)/.*$' + exclude: '^(doc|releasenotes)/.*$' diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..86036a6 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +[build-system] +requires = ["pbr>=6.1.1"] +build-backend = "pbr.build" + +[project] +name = "openstackclient" +description = "OpenStack Command-line Client" +authors = [ + {name = "OpenStack", email = "openstack-discuss@lists.openstack.org"}, +] +readme = {file = "README.rst", content-type = "text/x-rst"} +license = {text = "Apache-2.0"} +dynamic = ["version", "dependencies"] +requires-python = ">=3.10" +classifiers = [ + "Environment :: OpenStack", + "Intended Audience :: Information Technology", + "Intended Audience :: System Administrators", + "License :: OSI Approved :: Apache Software License", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python", + "Programming Language :: Python :: 3", +] + +[project.urls] +Homepage = "https://docs.openstack.org/python-openstackclient/" +Repository = "https://opendev.org/openstack/openstackclient/" + +[tool.ruff] +line-length = 79 + +[tool.ruff.format] +quote-style = "preserve" +docstring-code-format = true + +[tool.ruff.lint] +select = ["C4", "E4", "E5", "E7", "E9", "F", "G", "LOG", "S", "UP"] + +[tool.ruff.lint.per-file-ignores] +"openstackclient/tests/*" = ["S"] diff --git a/setup.cfg b/setup.cfg index c5e2f64..f87ba8b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,23 +1,2 @@ [metadata] name = openstackclient -summary = OpenStack Command-line Client -description_file = - README.rst -author = OpenStack -author_email = openstack-discuss@lists.openstack.org -home_page = https://docs.openstack.org/python-openstackclient/latest/ -python-requires = >=3.8 -classifier = - Environment :: OpenStack - Intended Audience :: Information Technology - Intended Audience :: System Administrators - License :: OSI Approved :: Apache Software License - Operating System :: POSIX :: Linux - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: 3.11 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: Implementation :: CPython diff --git a/tests/check_osc_commands.py b/tests/check_osc_commands.py index b98fe7d..d7531d7 100755 --- a/tests/check_osc_commands.py +++ b/tests/check_osc_commands.py @@ -99,7 +99,7 @@ def find_duplicates(): ep.load() except Exception: exc_string = traceback.format_exc() - message = "{}\n{}".format(ep.group, exc_string) + message = f"{ep.group}\n{exc_string}" failed_cmds.setdefault(ep_name, []).append(message) if _is_valid_command(ep_name, ep.group, valid_cmds):