Repository: archlinux/archinstall

Issue:
KeyError with select_disk
With the most recent commit ATM (0604ed4) I'm getting an KeyError with the following

```python
archinstall.select_disk(archinstall.all_blockdevices(partitions=False))
```

```
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/klim/tmp/archinstall/archinstall/lib/user_interaction/disk_conf.py", line 68, in select_disk
    f"{index}: {drive} ({dict_o_disks[drive]['size'], dict_o_disks[drive].device, dict_o_disks[drive]['label']})"
  File "/home/klim/tmp/archinstall/archinstall/lib/disk/blockdevice.py", line 42, in __getitem__
    raise KeyError(f'{self} does not contain information: "{key}"')
KeyError: 'BlockDevice(/dev/sda, size=476.9GB, free_space=, bus_type=sata) does not contain information: "size"'
```

To me it looks like the method `__getitem__` is not properly implemented for `BlockDevice`

```python
>>> import archinstall
>>> disks=archinstall.all_blockdevices(partitions=False)
>>> disks
{'/dev/sda4': BlockDevice(None, size=80.0GB, free_space=, bus_type=None), '/dev/sda2': BlockDevice(None, size=0.1GB, free_space=, bus_type=None), '/dev/sda5': BlockDevice(None, size=16.0GB, free_space=, bus_type=None), '/dev/sda3': BlockDevice(None, size=232.3GB, free_space=, bus_type=None), '/dev/sda1': BlockDevice(None, size=0.5GB, free_space=, bus_type=None), '/dev/sda': BlockDevice(/dev/sda, size=476.9GB, free_space=, bus_type=sata), '/dev/sda6': BlockDevice(None, size=148.0GB, free_space=, bus_type=None)}
>>> disks['/dev/sda']
BlockDevice(/dev/sda, size=476.9GB, free_space=, bus_type=sata)
>>> disks['/dev/sda'].size
476.9
>>> disks['/dev/sda']['size']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/klim/tmp/archinstall/archinstall/lib/disk/blockdevice.py", line 42, in __getitem__
    raise KeyError(f'{self} does not contain information: "{key}"')
KeyError: 'BlockDevice(/dev/sda, size=476.9GB, free_space=, bus_type=sata) does not contain information: "size"'
>>> disks['/dev/sda'].info
{'MAJOR': '8', 'MINOR': '0', 'DEVNAME': 'sda', 'DEVTYPE': 'disk', 'DISKSEQ': '1', 'path': '/dev/sda', 'PATH': '/dev/sda', 'PTTYPE': None}
>>>
```


Discussion:
Thank you for reporting this.
We've started to migrate to dataclasses and properties rather than relying on dictionaries.

`master` contains some of these changes and we've obviously missed to migrate some older code.
We should probably also introduce a deprecation layer here and support `["size"]` for a while longer.

I'll get this fixed before release!
@Torxed I can have a look at this one, I don't see any dataclasses for `Blockdevice` though, but it might be good to create one to store the information in a safer way
Ahh sorry maybe it is the `MapperDev` you meant 

Resolving patch:
diff --git a/archinstall/lib/disk/blockdevice.py b/archinstall/lib/disk/blockdevice.py
--- a/archinstall/lib/disk/blockdevice.py
+++ b/archinstall/lib/disk/blockdevice.py
@@ -7,12 +7,13 @@
 # https://stackoverflow.com/a/39757388/929999
 if TYPE_CHECKING:
 	from .partition import Partition
-	
+
 from ..exceptions import DiskError, SysCallError
 from ..output import log
 from ..general import SysCommand
 from ..storage import storage
 
+
 class BlockDevice:
 	def __init__(self, path :str, info :Optional[Dict[str, Any]] = None):
 		if not info:
@@ -38,7 +39,9 @@ def __iter__(self) -> Iterator[Partition]:
 			yield self.partitions[partition]
 
 	def __getitem__(self, key :str, *args :str, **kwargs :str) -> Any:
-		if key not in self.info:
+		if hasattr(self, key):
+			return getattr(self, key)
+		elif key not in self.info:
 			raise KeyError(f'{self} does not contain information: "{key}"')
 		return self.info[key]
 
diff --git a/archinstall/lib/disk/helpers.py b/archinstall/lib/disk/helpers.py
--- a/archinstall/lib/disk/helpers.py
+++ b/archinstall/lib/disk/helpers.py
@@ -221,10 +221,8 @@ def all_blockdevices(mappers=False, partitions=False, error=False) -> Dict[str,
 		device_path = f"/dev/{pathlib.Path(block_device).readlink().name}"
 		try:
 			information = blkid(f'blkid -p -o export {device_path}')
-
-		# TODO: No idea why F841 is raised here:
-		except SysCallError as error: # noqa: F841
-			if error.exit_code in (512, 2):
+		except SysCallError as ex:
+			if ex.exit_code in (512, 2):
 				# Assume that it's a loop device, and try to get info on it
 				try:
 					information = get_loop_info(device_path)
@@ -234,7 +232,7 @@ def all_blockdevices(mappers=False, partitions=False, error=False) -> Dict[str,
 				except SysCallError:
 					information = get_blockdevice_uevent(pathlib.Path(block_device).readlink().name)
 			else:
-				raise error
+				raise ex
 
 		information = enrich_blockdevice_information(information)
 


Test patch: