From c0a2de4330f6a1931a59f0a38cd17daea3a7920d Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Sun, 12 Jan 2025 04:02:06 +0000 Subject: [PATCH] Enable the set-attr-with-constant ruff rule and fix warnings (#3114) --- archinstall/lib/disk/device_model.py | 10 +++++----- pyproject.toml | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/archinstall/lib/disk/device_model.py b/archinstall/lib/disk/device_model.py index 485d6595..610798a3 100644 --- a/archinstall/lib/disk/device_model.py +++ b/archinstall/lib/disk/device_model.py @@ -142,8 +142,8 @@ class DiskLayoutConfiguration: flags=flags, btrfs_subvols=SubvolumeModification.parse_args(partition.get('btrfs', [])), ) - # special 'invisible attr to internally identify the part mod - setattr(device_partition, '_obj_id', partition['obj_id']) + # special 'invisible' attr to internally identify the part mod + device_partition._obj_id = partition['obj_id'] device_partitions.append(device_partition) device_modification.partitions = device_partitions @@ -867,7 +867,7 @@ class PartitionModification: def __post_init__(self) -> None: # needed to use the object as a dictionary key due to hash func if not hasattr(self, '_obj_id'): - self._obj_id = uuid.uuid4() + self._obj_id: uuid.UUID | str = uuid.uuid4() if self.is_exists_or_modify() and not self.dev_path: raise ValueError('If partition marked as existing a path must be set') @@ -1133,7 +1133,7 @@ class LvmVolume: def __post_init__(self) -> None: # needed to use the object as a dictionary key due to hash func if not hasattr(self, '_obj_id'): - self._obj_id = uuid.uuid4() + self._obj_id: uuid.UUID | str = uuid.uuid4() @override def __hash__(self) -> int: @@ -1193,7 +1193,7 @@ class LvmVolume: btrfs_subvols=SubvolumeModification.parse_args(arg.get('btrfs', [])) ) - setattr(volume, '_obj_id', arg['obj_id']) + volume._obj_id = arg['obj_id'] return volume diff --git a/pyproject.toml b/pyproject.toml index d9687382..46e2e598 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -209,7 +209,6 @@ select = [ ignore = [ "B006", # mutable-argument-default "B008", # function-call-in-default-argument - "B010", # set-attr-with-constant "B904", # raise-without-from-inside-except "B905", # zip-without-explicit-strict "PLC0415", # import-outside-top-level