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
8 changes: 3 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ jobs:
include:
# MANDATORY CHECKS USING CURRENT DEVELOPMENT INTERPRETER
- dependencies: >
pylint
python3-dbus
python3-dbus-python-client-gen
python3-justbytes
python3-gobject
python3-psutil
ruff
image: fedora:43 # CURRENT DEVELOPMENT ENVIRONMENT
task: PYTHONPATH=./src make -f Makefile lint
- dependencies: >
black
python3-isort
task: make -f Makefile lint
- dependencies: ruff
image: fedora:43 # CURRENT DEVELOPMENT ENVIRONMENT
task: make -f Makefile fmt-travis
# VERIFICATION OF TEST INFRASTRUCTURE
Expand Down
16 changes: 0 additions & 16 deletions .isort.cfg

This file was deleted.

22 changes: 5 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
.PHONY: lint
lint:
pylint test_harness.py
pylint stratis_cli_cert.py
pylint stratisd_cert.py
pylint testlib
pylint scripts --disable=duplicate-code
ruff check

.PHONY: fmt
fmt:
isort \
test_harness.py \
stratis_cli_cert.py \
stratisd_cert.py \
testlib scripts
black .
ruff check --fix --select I
ruff format

.PHONY: fmt-travis
fmt-travis:
isort --diff --check-only \
test_harness.py \
stratis_cli_cert.py \
stratisd_cert.py \
testlib scripts
black . --check
ruff check --select I
ruff format --check

.PHONY: yamllint
yamllint:
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tool.ruff]
target-version = "py312"
line-length = 88

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

[tool.ruff.lint.isort]
known-first-party = ["dbus_python_client_gen"]
split-on-trailing-comma = false
67 changes: 28 additions & 39 deletions scripts/monitor_dbus_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
_EMITS_CHANGED_PROP = "org.freedesktop.DBus.Property.EmitsChangedSignal"


class Diff: # pylint: disable=too-few-public-methods
class Diff:
"""
Diff between two different managed object results.
"""


class AddedProperty(Diff): # pylint: disable=too-few-public-methods
class AddedProperty(Diff):
"""
Property appears in new result but not in recorded result.
"""
Expand All @@ -71,7 +71,7 @@ def __repr__(self):
)


class RemovedProperty(Diff): # pylint: disable=too-few-public-methods
class RemovedProperty(Diff):
"""
Property appears in recorded result but not in new result.
"""
Expand All @@ -89,14 +89,12 @@ def __repr__(self):
)


class DifferentProperty(Diff): # pylint: disable=too-few-public-methods
class DifferentProperty(Diff):
"""
Difference between two properties.
"""

def __init__(
self, object_path, interface_name, key, old_value, new_value
): # pylint: disable=too-many-positional-arguments,too-many-arguments
def __init__(self, object_path, interface_name, key, old_value, new_value):
self.object_path = object_path
self.interface_name = interface_name
self.key = key
Expand All @@ -110,7 +108,7 @@ def __repr__(self):
)


class DifferentVariantLevel(Diff): # pylint: disable=too-few-public-methods
class DifferentVariantLevel(Diff):
"""
Represents a case where the property value is correct but the variant
level does not match. The variant levels among the GetManagedObjects
Expand All @@ -120,9 +118,7 @@ class DifferentVariantLevel(Diff): # pylint: disable=too-few-public-methods
they must be heterogeneous.
"""

def __init__(
self, object_path, interface_name, key, old_value, new_value
): # pylint: disable=too-many-positional-arguments,too-many-arguments
def __init__(self, object_path, interface_name, key, old_value, new_value):
self.object_path = object_path
self.interface_name = interface_name
self.key = key
Expand All @@ -137,15 +133,13 @@ def __repr__(self):
)


class NotInvalidatedProperty(Diff): # pylint: disable=too-few-public-methods
class NotInvalidatedProperty(Diff):
"""
Represents a case where the property should have been invalidated but
was updated instead.
"""

def __init__(
self, object_path, interface_name, key, old_value, new_value
): # pylint: disable=too-many-positional-arguments,too-many-arguments
def __init__(self, object_path, interface_name, key, old_value, new_value):
self.object_path = object_path
self.interface_name = interface_name
self.key = key
Expand All @@ -160,15 +154,13 @@ def __repr__(self):
)


class ChangedProperty(Diff): # pylint: disable=too-few-public-methods
class ChangedProperty(Diff):
"""
Represents a case where the property should have been constant but
seems to have changed.
"""

def __init__(
self, object_path, interface_name, key, old_value, new_value
): # pylint: disable=too-many-positional-arguments,too-many-arguments
def __init__(self, object_path, interface_name, key, old_value, new_value):
self.object_path = object_path
self.interface_name = interface_name
self.key = key
Expand All @@ -183,7 +175,7 @@ def __repr__(self):
)


class RemovedObjectPath(Diff): # pylint: disable=too-few-public-methods
class RemovedObjectPath(Diff):
"""
Object path appears in recorded result but not in new result.
"""
Expand All @@ -196,7 +188,7 @@ def __repr__(self):
return f"RemovedObjectPath({self.object_path!r}, {self.old_value!r})"


class AddedInterface(Diff): # pylint: disable=too-few-public-methods
class AddedInterface(Diff):
"""
Interface appears in new result but not in recorded result.
"""
Expand All @@ -213,7 +205,7 @@ def __repr__(self):
)


class AddedObjectPath(Diff): # pylint: disable=too-few-public-methods
class AddedObjectPath(Diff):
"""
Object path appears in new result but not in recorded result.
"""
Expand All @@ -226,7 +218,7 @@ def __repr__(self):
return f"AddedObjectPath({self.object_path!r}, {self.new_value!r})"


class RemovedInterface(Diff): # pylint: disable=too-few-public-methods
class RemovedInterface(Diff):
"""
Interface appears in recorded result but not in new result.
"""
Expand All @@ -243,7 +235,7 @@ def __repr__(self):
)


class MissingInterface(Diff): # pylint: disable=too-few-public-methods
class MissingInterface(Diff):
"""
Attempted to update a property on this interface, but the interface
itself was missing when that happened.
Expand Down Expand Up @@ -295,7 +287,7 @@ def from_str(code_str):
return item
return None

class Invalidated: # pylint: disable=too-few-public-methods
class Invalidated:
"""
Used to record in the updated GetManagedObjects value that a value has
been invalidated.
Expand All @@ -306,7 +298,7 @@ def __repr__(self):

INVALIDATED = Invalidated()

class InterfaceMissing: # pylint: disable=too-few-public-methods
class InterfaceMissing:
"""
Used to record in the updated GetManagedObjects value that when a
property changed signal was received, the interface for that property
Expand Down Expand Up @@ -424,7 +416,7 @@ def _interfaces_added(object_path, interfaces_added):
_MO[object_path][interface] = props
else:
_MO[object_path] = interfaces_added
except Exception as exc: # pylint: disable=broad-except
except Exception as exc:
_CALLBACK_ERRORS.append(exc)
Comment thread
mulkieran marked this conversation as resolved.

def _interfaces_removed(object_path, interfaces):
Expand Down Expand Up @@ -457,7 +449,7 @@ def _interfaces_removed(object_path, interfaces):
# that the object itself has been removed.
if _MO[object_path] == {}:
del _MO[object_path]
except Exception as exc: # pylint: disable=broad-except
except Exception as exc:
_CALLBACK_ERRORS.append(exc)

def _properties_changed(*props_changed, object_path=None):
Expand Down Expand Up @@ -524,7 +516,7 @@ def _properties_changed(*props_changed, object_path=None):
data[interface_name][prop] = value
for prop in properties_invalidated:
data[interface_name][prop] = INVALIDATED
except Exception as exc: # pylint: disable=broad-except
except Exception as exc:
_CALLBACK_ERRORS.append(exc)

def _monitor(
Expand All @@ -544,7 +536,7 @@ def _monitor(
:type interface_re: re.Pattern
"""

global _TOP_OBJECT, _TOP_OBJECT_PATH, _TOP_OBJECT_INTERFACES, _SERVICE, _MO, _INTERFACE_RE # pylint: disable=global-statement
global _TOP_OBJECT, _TOP_OBJECT_PATH, _TOP_OBJECT_INTERFACES, _SERVICE, _MO, _INTERFACE_RE # noqa: PLW0603

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()
Expand All @@ -556,7 +548,7 @@ def _monitor(
while True:
try:
_TOP_OBJECT = bus.get_object(service, _TOP_OBJECT_PATH)
except Exception as err: # pylint: disable=broad-exception-caught
except Exception as err:
print(
f'Failed to get top object "{_TOP_OBJECT_PATH}" for '
f'service "{_SERVICE}". Error: {err}. Retrying.'
Expand Down Expand Up @@ -588,7 +580,7 @@ def _monitor(
while True:
try:
_MO = _MAKE_MO()
except Exception as err: # pylint: disable=broad-exception-caught
except Exception as err:
print(
"Failed to get initial GetManagedObjects result for "
f'service "{_SERVICE}" and top object '
Expand Down Expand Up @@ -747,24 +739,21 @@ def _check():
if _MO is None:
return []

mos = _MAKE_MO() # pylint: disable=not-callable
mos = _MAKE_MO()

diffs = []

old_object_paths = frozenset(_MO.keys())
new_object_paths = frozenset(mos.keys())

for object_path in old_object_paths - new_object_paths:
diffs.append(
# pylint: disable=unsubscriptable-object
RemovedObjectPath(object_path, _MO[object_path])
)
diffs.append(RemovedObjectPath(object_path, _MO[object_path]))

for object_path in new_object_paths - old_object_paths:
diffs.append(AddedObjectPath(object_path, mos[object_path]))

for object_path in new_object_paths & old_object_paths:
old_data = _MO[object_path] # pylint: disable=unsubscriptable-object
old_data = _MO[object_path]
new_data = mos[object_path]

old_ifns = frozenset(old_data.keys())
Expand Down Expand Up @@ -792,7 +781,7 @@ def _check():

try:
result = _check()
except Exception as exco: # pylint: disable=broad-except
except Exception as exco:
print(f"{exco}")
sys.exit(4)

Expand Down
2 changes: 1 addition & 1 deletion scripts/monitor_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def run(namespace):
with open(
os.path.join(
namespace.output_dir,
f'{datetime.datetime.now().strftime("%Y_%m_%d-%I_%M_%S_%p")}.json',
f"{datetime.datetime.now().strftime('%Y_%m_%d-%I_%M_%S_%p')}.json",
),
mode="w",
encoding="utf-8",
Expand Down
7 changes: 2 additions & 5 deletions stratis_cli_cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"""
Tests of the stratis CLI.
"""
# pylint: disable=too-many-lines

# isort: STDLIB
import argparse
Expand Down Expand Up @@ -169,9 +168,7 @@ def test_access_stratis_man_page(self):
self._unittest_command(["man", "--where", "stratis"], 0, True, False)


class StratisCliCertify(
StratisdSystemdStart, StratisCertify
): # pylint: disable=too-many-public-methods
class StratisCliCertify(StratisdSystemdStart, StratisCertify):
"""
Unit tests for the stratis-cli package.
"""
Expand Down Expand Up @@ -1516,7 +1513,7 @@ def test_filesystem_mount_and_write(self):
[
"dd",
"if=/dev/urandom",
f'of={os.path.join(mountpoints[0], "file1")}',
f"of={os.path.join(mountpoints[0], 'file1')}",
"bs=4096",
"count=256",
"conv=fsync",
Expand Down
Loading