Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
# MANDATORY CHECKS USING CURRENT DEVELOPMENT INTERPRETER
- dependencies: >
libatomic
pylint
python3-dateutil
python3-dbus-client-gen
python3-dbus-python-client-gen
Expand All @@ -41,13 +40,10 @@ jobs:
python3-psutil
python3-setuptools
python3-wcwidth
task: >
PATH=${PATH}:/github/home/.local/bin PYTHONPATH=./src
make -f Makefile lint
- dependencies: black python3-isort
task:
PATH=${PATH}:/github/home/.local/bin PYTHONPATH=./src
make -f Makefile fmt-ci
ruff
task: PATH=${PATH}:/github/home/.local/bin make -f Makefile lint
- dependencies: ruff
task: PATH=${PATH}:/github/home/.local/bin make -f Makefile fmt-ci
runs-on: ubuntu-latest
container:
image: quay.io/fedora/fedora:43 # CURRENT DEVELOPMENT ENVIRONMENT
Expand Down
16 changes: 0 additions & 16 deletions .isort.cfg

This file was deleted.

20 changes: 8 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
ISORT_MODULES = setup.py bin/stratis src tests

UNITTEST_OPTS = --verbose

PYLINT_DISABLE = --disable=fixme

.PHONY: lint
lint:
pylint setup.py ${PYLINT_DISABLE}
pylint bin/stratis ${PYLINT_DISABLE}
pylint src/stratis_cli --disable=duplicate-code ${PYLINT_DISABLE} --ignore=_introspect.py
pylint tests --disable=duplicate-code ${PYLINT_DISABLE}
ruff check bin/stratis
ruff check
pyright
Comment thread
coderabbitai[bot] marked this conversation as resolved.

.PHONY: fmt
fmt:
isort ${ISORT_MODULES}
black ./bin/stratis .
ruff check --fix --select I bin/stratis
ruff check --fix --select I
ruff format

.PHONY: fmt-ci
fmt-ci:
isort --diff --check-only ${ISORT_MODULES}
black ./bin/stratis . --check
ruff check --select I bin/stratis
ruff check --select I
ruff format --check
Comment thread
mulkieran marked this conversation as resolved.

.PHONY: check-typos
check-typos:
Expand Down
2 changes: 0 additions & 2 deletions bin/stratis
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
Entry script for stratis CLI.
"""

# isort: STDLIB
import sys

# isort: LOCAL
from stratis_cli import StratisCliEnvironmentError, StratisCliErrorCodes, exit_, run

try:
Expand Down
14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,17 @@ build-backend = "setuptools.build_meta"
[tool.pyright]
include = ["src", "tests", "bin"]
pythonVersion = "3.12"

[tool.ruff]
target-version = "py312"
line-length = 88

[tool.ruff.lint]
select = ["PL"]

[tool.ruff.lint.isort]
known-first-party = ["dbus_client_gen", "dbus_python_client_gen"]
split-on-trailing-comma = false

[tool.ruff.format]
skip-magic-trailing-comma = true
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Python packaging file for setup tools.
"""

# isort: THIRDPARTY
import setuptools

setuptools.setup()
1 change: 1 addition & 0 deletions src/stratis_cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
Top level of CLI.
"""

from ._errors import StratisCliEnvironmentError
from ._exit import StratisCliErrorCodes, exit_
from ._main import run
21 changes: 6 additions & 15 deletions src/stratis_cli/_actions/_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Miscellaneous pool-binding actions.
"""

# isort: STDLIB
import json
from argparse import Namespace

Expand Down Expand Up @@ -54,8 +53,7 @@ def bind_clevis(namespace: Namespace):
discussion of the pin and the configuration, consult Clevis
documentation.
"""
# pylint: disable=import-outside-toplevel
from ._data import ObjectManager, Pool, pools
from ._data import ObjectManager, Pool, pools # noqa: PLC0415

proxy = get_object(TOP_OBJECT)
managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
Expand Down Expand Up @@ -90,8 +88,7 @@ def bind_keyring(namespace: Namespace):
"""
Bind all devices in an encrypted pool using the kernel keyring.
"""
# pylint: disable=import-outside-toplevel
from ._data import ObjectManager, Pool, pools
from ._data import ObjectManager, Pool, pools # noqa: PLC0415

proxy = get_object(TOP_OBJECT)
managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
Expand All @@ -105,10 +102,7 @@ def bind_keyring(namespace: Namespace):
)
(changed, return_code, return_msg) = Pool.Methods.BindKeyring(
get_object(pool_object_path),
{
"key_desc": namespace.keydesc,
"token_slot": (False, 0),
},
{"key_desc": namespace.keydesc, "token_slot": (False, 0)},
)

if return_code != StratisdErrors.OK:
Expand All @@ -125,8 +119,7 @@ def unbind(namespace: Namespace):
:raises StratisCliNoChangeError:
:raises StratisCliEngineError:
"""
# pylint: disable=import-outside-toplevel
from ._data import ObjectManager, Pool, pools
from ._data import ObjectManager, Pool, pools # noqa: PLC0415

proxy = get_object(TOP_OBJECT)
managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
Expand Down Expand Up @@ -173,8 +166,7 @@ def rebind_clevis(namespace: Namespace):
"""
Rebind with Clevis nbde/tang
"""
# pylint: disable=import-outside-toplevel
from ._data import ObjectManager, Pool, pools
from ._data import ObjectManager, Pool, pools # noqa: PLC0415

pool_id = _get_pool_id(namespace)

Expand Down Expand Up @@ -210,8 +202,7 @@ def rebind_keyring(namespace: Namespace):
"""
Rebind with a kernel keyring
"""
# pylint: disable=import-outside-toplevel
from ._data import ObjectManager, Pool, pools
from ._data import ObjectManager, Pool, pools # noqa: PLC0415

keydesc = namespace.keydesc

Expand Down
3 changes: 0 additions & 3 deletions src/stratis_cli/_actions/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Low-level interactions with the D-Bus.
"""

# isort: THIRDPARTY
import dbus

from ._constants import SERVICE
Expand All @@ -26,8 +25,6 @@ class Bus:
Our bus.
"""

# pylint: disable=too-few-public-methods

_BUS = None

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion src/stratis_cli/_actions/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""
General constants.
"""
# isort: THIRDPARTY

from packaging.version import Version

SERVICE = "org.storage.stratis3"
Expand Down
18 changes: 5 additions & 13 deletions src/stratis_cli/_actions/_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Miscellaneous whole pool encryption actions.
"""

# isort: STDLIB
import json
from argparse import Namespace

Expand Down Expand Up @@ -47,8 +46,7 @@ def encrypt(namespace: Namespace):
if not namespace.in_place:
raise StratisCliInPlaceNotSpecified()

# pylint: disable=import-outside-toplevel
from ._data import MOPool, ObjectManager, Pool, pools
from ._data import MOPool, ObjectManager, Pool, pools # noqa: PLC0415

pool_id = PoolId.from_parser_namespace(namespace)
assert pool_id is not None
Expand Down Expand Up @@ -108,8 +106,7 @@ def unencrypt(namespace: Namespace):
if not namespace.in_place:
raise StratisCliInPlaceNotSpecified()

# pylint: disable=import-outside-toplevel
from ._data import MOPool, ObjectManager, Pool, pools
from ._data import MOPool, ObjectManager, Pool, pools # noqa: PLC0415

pool_id = PoolId.from_parser_namespace(namespace)
assert pool_id is not None
Expand All @@ -128,9 +125,7 @@ def unencrypt(namespace: Namespace):
raise StratisCliNoChangeError("encryption off", pool_id)

(changed, return_code, message) = Pool.Methods.DecryptPool(
get_object(pool_object_path),
{},
timeout=10,
get_object(pool_object_path), {}, timeout=10
)

if return_code != StratisdErrors.OK: # pragma: no cover
Expand All @@ -152,8 +147,7 @@ def reencrypt(namespace: Namespace):
if not namespace.in_place:
raise StratisCliInPlaceNotSpecified()

# pylint: disable=import-outside-toplevel
from ._data import ObjectManager, Pool, pools
from ._data import ObjectManager, Pool, pools # noqa: PLC0415

pool_id = PoolId.from_parser_namespace(namespace)
assert pool_id is not None
Expand All @@ -169,9 +163,7 @@ def reencrypt(namespace: Namespace):
)

(changed, return_code, message) = Pool.Methods.ReencryptPool(
get_object(pool_object_path),
{},
timeout=10,
get_object(pool_object_path), {}, timeout=10
)

if return_code != StratisdErrors.OK:
Expand Down
11 changes: 4 additions & 7 deletions src/stratis_cli/_actions/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
"""
XML interface specifications.
"""
# isort: STDLIB

import os
import sys
import xml.etree.ElementTree as ET

# isort: FIRSTPARTY
from dbus_client_gen import (
DbusClientGenerationError,
managed_object_class,
Expand Down Expand Up @@ -66,8 +65,6 @@


try:
# pylint: disable=invalid-name

timeout = get_timeout(
os.environ.get("STRATIS_DBUS_TIMEOUT", str(DBUS_TIMEOUT_SECONDS * 1000))
)
Expand Down Expand Up @@ -131,9 +128,9 @@ def new_method(proxy, args):
New CreatePool method
"""
rel_paths = [path for path in args[key] if not os.path.isabs(path)]
assert (
rel_paths == []
), f"Precondition violated: paths {', '.join(rel_paths)} should be absolute"
assert rel_paths == [], (
f"Precondition violated: paths {', '.join(rel_paths)} should be absolute"
)
return orig_method(proxy, args)

setattr(method_class, method_name, new_method)
Expand Down
Loading
Loading