Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
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: 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
20 changes: 6 additions & 14 deletions src/stratis_cli/_actions/_bind.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,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 +89,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 +103,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 +120,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 +167,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 +203,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
2 changes: 0 additions & 2 deletions src/stratis_cli/_actions/_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Bus:
Our bus.
"""

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

_BUS = None

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions src/stratis_cli/_actions/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
General constants.
"""

# isort: THIRDPARTY
from packaging.version import Version

Expand Down
17 changes: 5 additions & 12 deletions src/stratis_cli/_actions/_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,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 +107,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 +126,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 +148,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 +164,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
9 changes: 4 additions & 5 deletions src/stratis_cli/_actions/_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""
XML interface specifications.
"""

# isort: STDLIB
import os
import sys
Expand Down Expand Up @@ -66,8 +67,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 +130,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
25 changes: 10 additions & 15 deletions src/stratis_cli/_actions/_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from ._constants import TOP_OBJECT


class TopDebugActions: # pylint: disable=too-few-public-methods
class TopDebugActions:
"""
Top level object debug actions.
"""
Expand All @@ -37,7 +37,7 @@ def refresh_state(_namespace: Namespace):
"""
Refresh pools from their metadata up.
"""
from ._data import Manager # pylint: disable=import-outside-toplevel
from ._data import Manager # noqa: PLC0415

(return_code, message) = Manager.Methods.RefreshState(
get_object(TOP_OBJECT), {}
Expand Down Expand Up @@ -66,7 +66,7 @@ def send_uevent(namespace: Namespace):
) from err


class PoolDebugActions: # pylint: disable=too-few-public-methods
class PoolDebugActions:
"""
Pool debug actions.
"""
Expand All @@ -79,8 +79,7 @@ def get_object_path(namespace: Namespace):
:raises StratisCliEngineError:
"""

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

proxy = get_object(TOP_OBJECT)
managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
Expand All @@ -98,8 +97,7 @@ def get_metadata(namespace: Namespace):
"""
Get some information about the pool-level metadata.
"""
# 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 @@ -125,7 +123,7 @@ def get_metadata(namespace: Namespace):
print(json.dumps(json.loads(metadata)))


class FilesystemDebugActions: # pylint: disable=too-few-public-methods
class FilesystemDebugActions:
"""
Filesystem debug actions.
"""
Expand All @@ -138,8 +136,7 @@ def get_object_path(namespace: Namespace):
:raises StratisCliEngineError:
"""

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

proxy = get_object(TOP_OBJECT)
managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
Expand All @@ -161,8 +158,7 @@ def get_metadata(namespace: Namespace):
: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 @@ -194,7 +190,7 @@ def get_metadata(namespace: Namespace):
print(json.dumps(json.loads(metadata)))


class BlockdevDebugActions: # pylint: disable=too-few-public-methods
class BlockdevDebugActions:
"""
Blockdev debug actions.
"""
Expand All @@ -207,8 +203,7 @@ def get_object_path(namespace: Namespace):
:raises StratisCliEngineError:
"""

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

proxy = get_object(TOP_OBJECT)
managed_objects = ObjectManager.Methods.GetManagedObjects(proxy, {})
Expand Down
Loading
Loading