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
2 changes: 1 addition & 1 deletion archinstall/lib/disk/device_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def get_uuid_for_path(self, path: Path) -> str | None:

def get_btrfs_info(
self,
dev_path: Path,
dev_path: Path | str,
lsblk_info: LsblkInfo | None = None,
) -> list[_BtrfsSubvolumeInfo]:
if not lsblk_info:
Expand Down
4 changes: 2 additions & 2 deletions archinstall/lib/disk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def udev_sync() -> None:


def mount(
dev_path: Path,
dev_path: Path | str,
target_mountpoint: Path,
mount_fs: str | None = None,
create_target_mountpoint: bool = True,
Expand Down Expand Up @@ -173,7 +173,7 @@ def mount(
raise DiskError(f'Could not mount {dev_path}: {command}\n{err.message}')


def umount(mountpoint: Path, recursive: bool = False) -> None:
def umount(mountpoint: Path | str, recursive: bool = False) -> None:
lsblk_info = get_lsblk_info(mountpoint)

if not lsblk_info.mountpoints:
Expand Down
13 changes: 6 additions & 7 deletions archinstall/lib/models/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ def from_partition(
)

length = Size(
int(partition.getLength(unit='B')),
partition.getLength(unit='B'),
Unit.B,
SectorSize(partition.disk.device.sectorSize, Unit.B),
)
Expand Down Expand Up @@ -646,7 +646,7 @@ def from_disk(cls, disk: Disk) -> Self:
path=Path(device.path),
type=device_type,
sector_size=sector_size,
total_size=Size(int(device.getLength(unit='B')), Unit.B, sector_size),
total_size=Size(device.getLength(unit='B'), Unit.B, sector_size),
free_space_regions=free_space,
read_only=device.readOnly,
dirty=device.dirty,
Expand Down Expand Up @@ -764,12 +764,11 @@ def get_type_from_code(code: int) -> PartitionType:
debug(f'Partition code not supported: {code}')
return PartitionType._UNKNOWN

def get_partition_code(self) -> int | None:
if self == PartitionType.PRIMARY:
return parted.PARTITION_NORMAL
elif self == PartitionType.BOOT:
def get_partition_code(self) -> int:
if self == PartitionType.BOOT:
return parted.PARTITION_BOOT
return None

return parted.PARTITION_NORMAL


@dataclass(frozen=True)
Expand Down
20 changes: 0 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,6 @@ disallow_any_explicit = true
module = "archinstall.lib.*"
warn_return_any = false

[[tool.mypy.overrides]]
module = "archinstall.lib.disk.*"
# 'Any' imports are allowed because pyparted doesn't have type hints
disallow_any_unimported = false

[[tool.mypy.overrides]]
module = "archinstall.lib.models.*"
# 'Any' imports are allowed because pyparted doesn't have type hints
disallow_any_unimported = false

[[tool.mypy.overrides]]
module = "archinstall.lib.packages"
disallow_any_explicit = true
Expand All @@ -123,12 +113,6 @@ disallow_any_explicit = true
module = "archinstall.lib.utils"
disallow_any_explicit = true

[[tool.mypy.overrides]]
module = [
"parted",
]
ignore_missing_imports = true

[tool.bandit]
targets = ["archinstall"]
exclude = ["/tests"]
Expand Down Expand Up @@ -178,10 +162,6 @@ init-import = true
[tool.pyrefly]
python-version = "3.14"

replace-imports-with-any = [
"parted", # pyparted doesn't have type hints
]

[tool.pyrefly.errors]
# Enable some additional rules that are disabled by default
implicit-abstract-class = true
Expand Down
88 changes: 88 additions & 0 deletions stubs/parted/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
DEVICE_UNKNOWN: int
PARTITION_NORMAL: int
PARTITION_BOOT: int
PARTITION_ESP: int
PARTITION_BLS_BOOT: int
PARTITION_LINUX_HOME: int
PARTITION_SWAP: int

class IOException(Exception): ...
class DiskException(Exception): ...
class PartitionException(Exception): ...
class Constraint: ...

class Device:
@property
def model(self) -> str: ...
@property
def path(self) -> str: ...
@property
def type(self) -> int: ...
@property
def sectorSize(self) -> int: ...
@property
def readOnly(self) -> bool: ...
@property
def dirty(self) -> bool: ...
@property
def optimalAlignedConstraint(self) -> Constraint: ...
def getLength(self, unit: str = ...) -> int: ...

class Geometry:
start: int
end: int

def __init__(self, device: Device, start: int, length: int) -> None: ...
@property
def device(self) -> Device: ...
def getLength(self, unit: str = ...) -> int: ...

class FileSystem:
def __init__(
self,
type: str, # pylint: disable=redefined-builtin
geometry: Geometry,
) -> None: ...
@property
def type(self) -> str: ...

class Disk:
@property
def device(self) -> Device: ...
@property
def type(self) -> str: ...
@property
def partitions(self) -> list[Partition]: ...
def commit(self) -> None: ...
def addPartition(self, partition: Partition, constraint: Constraint) -> None: ...
def deletePartition(self, partition: Partition) -> None: ...
def getFreeSpaceRegions(self) -> list[Geometry]: ...

class Partition:
fileSystem: FileSystem | None
geometry: Geometry
type: int
type_uuid: bytes

def __init__(
self,
disk: Disk,
type: int, # pylint: disable=redefined-builtin
fs: FileSystem,
geometry: Geometry,
) -> None: ...
@property
def disk(self) -> Disk: ...
@property
def path(self) -> str: ...
def get_name(self) -> str: ...
def getFlag(self, flag: int) -> int: ...
def setFlag(self, flag: int) -> None: ...
def getLength(self, unit: str = ...) -> int: ...

def getAllDevices() -> list[Device]: ...
def getDevice(device: str) -> Device: ...
def newDisk(device: Device) -> Disk: ...
def freshDisk(device: Device, label: str) -> Disk: ...

devices: dict[int, str]