Migrate to pyproject.toml and ruff

We also bump the pre-commit versions used.

Change-Id: I0662b6cc7efd58e9fcf6e936dc5556fcc8492ddf
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2025-12-11 13:11:09 +00:00
parent 10b0a3a8a8
commit de791e785a
4 changed files with 50 additions and 33 deletions

View File

@@ -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)/.*$'

40
pyproject.toml Normal file
View File

@@ -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"]

View File

@@ -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

View File

@@ -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):