Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradvaithm <advaith.madhukar@gmail.com>2021-05-12 15:45:45 +0530
committeradvaithm <advaith.madhukar@gmail.com>2021-05-12 15:45:45 +0530
commit69d079e63a00caf9268575a6ca4789962776761b (patch)
tree36f37872628fad6fe31711b23412f6e6e215f5e0
parentf45f036b6557859649c9b3d670d89b578c01067f (diff)
some type hint fixes and a bad catch fix
-rw-r--r--.vscode/settings.json3
-rw-r--r--archinstall/lib/disk.py5
-rw-r--r--archinstall/lib/general.py9
-rw-r--r--archinstall/lib/hardware.py1
-rw-r--r--archinstall/lib/output.py2
-rw-r--r--archinstall/lib/profiles.py5
-rw-r--r--examples/__init__.py0
-rw-r--r--profiles/__init__.py0
-rw-r--r--profiles/applications/__init__.py0
-rw-r--r--setup.py2
10 files changed, 17 insertions, 10 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..d2a6c127
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "python.pythonPath": "/usr/bin/python"
+} \ No newline at end of file
diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py
index 44462a21..fd08ea63 100644
--- a/archinstall/lib/disk.py
+++ b/archinstall/lib/disk.py
@@ -1,3 +1,4 @@
+from typing import Optional
import glob, re, os, json, time, hashlib
import pathlib, traceback, logging
from collections import OrderedDict
@@ -205,7 +206,7 @@ class Partition():
return f'Partition(path={self.path}, size={self.size}, fs={self.filesystem}{mount_repr})'
@property
- def uuid(self) -> str:
+ def uuid(self) -> Optional[str]:
"""
Returns the PARTUUID as returned by lsblk.
This is more reliable than relying on /dev/disk/by-partuuid as
@@ -214,7 +215,7 @@ class Partition():
lsblk = b''.join(sys_command(f'lsblk -J -o+PARTUUID {self.path}'))
for partition in json.loads(lsblk.decode('UTF-8'))['blockdevices']:
return partition.get('partuuid', None)
-
+ return None
@property
def encrypted(self):
return self._encrypted
diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py
index eb0c5d14..72f8677f 100644
--- a/archinstall/lib/general.py
+++ b/archinstall/lib/general.py
@@ -5,6 +5,7 @@ from subprocess import Popen, STDOUT, PIPE, check_output
from select import epoll, EPOLLIN, EPOLLHUP
from .exceptions import *
from .output import log
+from typing import Optional, Union
def gen_uid(entropy_length=256):
return hashlib.sha512(os.urandom(entropy_length)).hexdigest()
@@ -160,16 +161,15 @@ class sys_command():#Thread):
'exit_code': self.exit_code
}
- def peak(self, output :str):
+ def peak(self, output : Union[str, bytes]) -> bool:
if type(output) == bytes:
try:
output = output.decode('UTF-8')
except UnicodeDecodeError:
- return None
-
+ return False
output = output.strip('\r\n ')
if len(output) <= 0:
- return None
+ return False
if self.peak_output:
from .user_interaction import get_terminal_width
@@ -191,6 +191,7 @@ class sys_command():#Thread):
# And print the new output we're peaking on:
sys.stdout.write(output)
sys.stdout.flush()
+ return True
def run(self):
self.status = 'running'
diff --git a/archinstall/lib/hardware.py b/archinstall/lib/hardware.py
index 185ec1d6..009a3a6c 100644
--- a/archinstall/lib/hardware.py
+++ b/archinstall/lib/hardware.py
@@ -91,6 +91,7 @@ def cpuVendor()-> Optional[str]:
if info.get('field',None):
if info.get('field',None) == "Vendor ID:":
return info.get('data',None)
+ return None
def isVM() -> bool:
try:
diff --git a/archinstall/lib/output.py b/archinstall/lib/output.py
index 06d99778..d6a197f1 100644
--- a/archinstall/lib/output.py
+++ b/archinstall/lib/output.py
@@ -19,7 +19,7 @@ class journald(dict):
@abc.abstractmethod
def log(message, level=logging.DEBUG):
try:
- import systemd.journal
+ import systemd.journal # type: ignore
except ModuleNotFoundError:
return False
diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py
index 06237c1c..1feba1cd 100644
--- a/archinstall/lib/profiles.py
+++ b/archinstall/lib/profiles.py
@@ -1,3 +1,4 @@
+from typing import Optional
import os, urllib.request, urllib.parse, ssl, json, re
import importlib.util, sys, glob, hashlib, logging
from collections import OrderedDict
@@ -49,7 +50,7 @@ def list_profiles(filter_irrelevant_macs=True, subpath='', filter_top_level_prof
except urllib.error.HTTPError as err:
print(f'Error: Listing profiles on URL "{profiles_url}" resulted in:', err)
return cache
- except:
+ except json.decoder.JSONDecodeError as err:
print(f'Error: Could not decode "{profiles_url}" result as JSON:', err)
return cache
@@ -215,7 +216,7 @@ class Profile(Script):
return True
@property
- def packages(self) -> list:
+ def packages(self) -> Optional[list]:
"""
Returns a list of packages baked into the profile definition.
If no package definition has been done, .packages() will return None.
diff --git a/examples/__init__.py b/examples/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/examples/__init__.py
diff --git a/profiles/__init__.py b/profiles/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/profiles/__init__.py
diff --git a/profiles/applications/__init__.py b/profiles/applications/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/profiles/applications/__init__.py
diff --git a/setup.py b/setup.py
index a4f49f92..8b95d978 100644
--- a/setup.py
+++ b/setup.py
@@ -1,2 +1,2 @@
-import setuptools
+import setuptools # type: ignore
setuptools.setup()