Fix pylint issue E0606: possibly-used-before-assignment

Fix:
assemblers/org.osbuild.qemu:310:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
inputs/org.osbuild.tree:85:15: E0606: Possibly using variable 'path' before assignment (possibly-used-before-assignment)
stages/org.osbuild.sfdisk:58:36: E0606: Possibly using variable 'prep_type' before assignment (possibly-used-before-assignment)
stages/org.osbuild.systemd.unit:23:16: E0606: Possibly using variable 'unit_dropins_dir' before assignment (possibly-used-before-assignment)
test/mod/test_meta.py:219:29: E0606: Possibly using variable 'schema_part' before assignment (possibly-used-before-assignment)

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2024-11-19 13:36:20 +01:00 committed by Michael Vogt
parent 7f86ccc7fc
commit 3ac6d405b5
5 changed files with 10 additions and 0 deletions

View file

@ -305,6 +305,8 @@ class PartitionTable:
prep_type = "41"
elif self.label == "gpt":
prep_type = "9E1A2D38-C612-4316-AA26-8B49521E5A8B"
else:
raise RuntimeError(f"Unknown partition table type: {self.label}")
for part in self.partitions:
if part.type.upper() == prep_type:

View file

@ -79,6 +79,7 @@ class TreeInput(inputs.InputService):
# and we have exactly one reference, i.e. a pipeline id
pid, _ = refs.popitem()
path = None
if pid:
path = store.read_tree_at(pid, target)

View file

@ -53,6 +53,8 @@ class PartitionTable:
prep_type = "41"
elif self.label == "gpt":
prep_type = "9E1A2D38-C612-4316-AA26-8B49521E5A8B"
else:
raise RuntimeError(f"Unknown partition table type: {self.label}")
for part in self.partitions:
if part.type.upper() == prep_type:

View file

@ -20,6 +20,10 @@ def main(tree, options):
unit_dropins_dir = f"{tree}/usr/lib/systemd/system/{unit}.d"
elif unit_type == "global":
unit_dropins_dir = f"{tree}/usr/lib/systemd/user/{unit}.d"
else:
print(f"Error: Unknown unit type: {unit_type}")
return 1
os.makedirs(unit_dropins_dir, exist_ok=True)
# We trick configparser into letting us write multiple instances of the same option by writing them as keys with no

View file

@ -206,6 +206,7 @@ def make_fake_meta_json(tmp_path, name, version, invalid=""):
"not": "following schema"
"""
# pylint: disable=possibly-used-before-assignment
meta_json_path.write_text("""
{
"summary": "some json summary",