Skip to content

Commit a6dca77

Browse files
authored
Merge pull request #1265 from mulkieran/add-type-annotations
Add type annotations to extend-data methods
2 parents 408e33b + 66c0f76 commit a6dca77

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/stratis_cli/_actions/_pool.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
from argparse import Namespace
2222
from collections import defaultdict
2323
from itertools import tee
24-
from typing import Dict
24+
from typing import Dict, Generator, List, Sequence
2525
from uuid import UUID
2626

2727
# isort: THIRDPARTY
2828
from dbus import Dictionary
29+
from dbus.proxies import ProxyObject
2930
from justbytes import Range
3031

3132
# isort: FIRSTPARTY
@@ -653,7 +654,7 @@ def extend_data(namespace: Namespace): # pylint: disable=too-many-locals
653654
)
654655
)
655656

656-
def expandable(modev):
657+
def expandable(modev) -> bool:
657658
"""
658659
Return true if the new size is greater than total.
659660
@@ -668,7 +669,7 @@ def expandable(modev):
668669
else new_size > Range(modev.TotalPhysicalSize())
669670
)
670671

671-
def expand(pool_proxy, modev): # pragma: no cover
672+
def expand(pool_proxy: ProxyObject, modev): # pragma: no cover
672673
"""
673674
Expand a pool by extending exactly one expandable device in the
674675
pool.
@@ -692,7 +693,9 @@ def expand(pool_proxy, modev): # pragma: no cover
692693
)
693694
)
694695

695-
def get_devices_to_expand(device_uuids, modevs):
696+
def get_devices_to_expand(
697+
device_uuids: Sequence[UUID], modevs: Generator
698+
) -> List:
696699
"""
697700
Calculate devices to expand
698701
:param device_uuids: a list of device uuids, if empty expand all
@@ -704,12 +707,12 @@ def get_devices_to_expand(device_uuids, modevs):
704707
if device_uuids == []:
705708
expand_modevs = [modev for modev in modevs if expandable(modev)]
706709
else:
707-
device_uuids = frozenset(uuid.hex for uuid in device_uuids)
710+
device_uuid_set = frozenset(uuid.hex for uuid in device_uuids)
708711
expand_modevs = [
709-
modev for modev in modevs if modev.Uuid() in device_uuids
712+
modev for modev in modevs if modev.Uuid() in device_uuid_set
710713
]
711-
if len(expand_modevs) < len(device_uuids):
712-
missing_uuids = device_uuids.difference(
714+
if len(expand_modevs) < len(device_uuid_set):
715+
missing_uuids = device_uuid_set.difference(
713716
frozenset(UUID(modev.Uuid()) for modev in expand_modevs)
714717
)
715718

0 commit comments

Comments
 (0)