Automatic fixes to Python files

check=True was manually set when return code was checked later
This commit is contained in:
Geoffrey Frogeye 2025-05-08 17:56:11 +02:00
parent a3f4c2a932
commit 34b545890d
7 changed files with 22 additions and 33 deletions

View file

@ -19,9 +19,8 @@ def process_flake(flakeUri: str) -> None:
if not os.path.isfile(flakeFile): if not os.path.isfile(flakeFile):
raise FileNotFoundError(f"Flake not found: {flakeUri}") raise FileNotFoundError(f"Flake not found: {flakeUri}")
# import dependencies # import dependencies
p = subprocess.run(GET_INPUTS_CMD, cwd=flakeUri, stdout=subprocess.PIPE) p = subprocess.run(GET_INPUTS_CMD, cwd=flakeUri, stdout=subprocess.PIPE, check=True)
deps = json.loads(p.stdout) deps = json.loads(p.stdout)
p.check_returncode()
# for each dependency # for each dependency
for dep_name, dep in deps.items(): for dep_name, dep in deps.items():
dep_url = dep["url"] dep_url = dep["url"]
@ -47,8 +46,7 @@ def process_flake(flakeUri: str) -> None:
"update", "update",
dep_name, dep_name,
] ]
p = subprocess.run(cmd, cwd=flakeUri) p = subprocess.run(cmd, cwd=flakeUri, check=True)
p.check_returncode()
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -133,7 +133,7 @@ class Desk:
self._reset_estimations() self._reset_estimations()
self.last_destination = None self.last_destination = None
self.fetch_callback: typing.Callable[["Desk"], None] | None = None self.fetch_callback: typing.Callable[[Desk], None] | None = None
def _get_report(self) -> bytes: def _get_report(self) -> bytes:
raw = self._get(4) raw = self._get(4)
@ -170,7 +170,6 @@ class Desk:
if start_val < self.destination: if start_val < self.destination:
end_val = start_val + delta_u end_val = start_val + delta_u
return min(end_val, self.destination) return min(end_val, self.destination)
else:
end_val = start_val - delta_u end_val = start_val - delta_u
return max(end_val, self.destination) return max(end_val, self.destination)
@ -260,7 +259,6 @@ class Desk:
def get_height(self) -> float | None: def get_height(self) -> float | None:
if self.est_value is None: if self.est_value is None:
return None return None
else:
return self._unitToCm(self.est_value) return self._unitToCm(self.est_value)

View file

@ -40,7 +40,6 @@ def humanSize(numi: int) -> str:
if abs(num) < 1000: if abs(num) < 1000:
if num >= 10: if num >= 10:
return f"{int(num):3d}{unit}" return f"{int(num):3d}{unit}"
else:
return f"{num:.1f}{unit}" return f"{num:.1f}{unit}"
num /= 1024 num /= 1024
return f"{numi:d}YiB" return f"{numi:d}YiB"
@ -127,7 +126,7 @@ class Section(ComposableText):
color: rich.color.Color = rich.color.Color.default(), color: rich.color.Color = rich.color.Color.default(),
) -> None: ) -> None:
super().__init__(parent=parent, sortKey=sortKey) super().__init__(parent=parent, sortKey=sortKey)
self.parent: "Module" self.parent: Module
self.color = color self.color = color
self.desiredText: str | None = None self.desiredText: str | None = None
@ -216,7 +215,7 @@ class Module(ComposableText):
def __init__(self, parent: "Side") -> None: def __init__(self, parent: "Side") -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
self.parent: "Side" self.parent: Side
self.children: typing.MutableSequence[Section] self.children: typing.MutableSequence[Section]
self.mirroring: Module | None = None self.mirroring: Module | None = None
@ -229,7 +228,6 @@ class Module(ComposableText):
def getSections(self) -> typing.Sequence[Section]: def getSections(self) -> typing.Sequence[Section]:
if self.mirroring: if self.mirroring:
return self.mirroring.children return self.mirroring.children
else:
return self.children return self.children
def updateMarkup(self) -> None: def updateMarkup(self) -> None:
@ -276,8 +274,7 @@ class Side(ComposableText):
text += "" text += ""
else: else:
text += "%{F" + hexa + "}%{R}" text += "%{F" + hexa + "}%{R}"
else: elif lastSection.color == section.color:
if lastSection.color == section.color:
text += "" text += ""
else: else:
text += "%{R}%{B" + hexa + "}" text += "%{R}%{B" + hexa + "}"
@ -292,7 +289,7 @@ class Side(ComposableText):
class Screen(ComposableText): class Screen(ComposableText):
def __init__(self, parent: "Bar", output: str) -> None: def __init__(self, parent: "Bar", output: str) -> None:
super().__init__(parent=parent) super().__init__(parent=parent)
self.parent: "Bar" self.parent: Bar
self.children: typing.MutableSequence[Side] self.children: typing.MutableSequence[Side]
self.output = output self.output = output
@ -323,7 +320,7 @@ class Bar(ComposableText):
self.refresh = asyncio.Event() self.refresh = asyncio.Event()
self.taskGroup = asyncio.TaskGroup() self.taskGroup = asyncio.TaskGroup()
self.providers: list["Provider"] = list() self.providers: list[Provider] = list()
self.actionIndex = 0 self.actionIndex = 0
self.actions: dict[str, typing.Callable] = dict() self.actions: dict[str, typing.Callable] = dict()
@ -547,7 +544,7 @@ class MultiSectionsProvider(Provider):
self.updaters: dict[Section, typing.Callable] = dict() self.updaters: dict[Section, typing.Callable] = dict()
async def getSectionUpdater(self, section: Section) -> typing.Callable: async def getSectionUpdater(self, section: Section) -> typing.Callable:
raise NotImplementedError() raise NotImplementedError
@staticmethod @staticmethod
async def doNothing() -> None: async def doNothing() -> None:
@ -584,7 +581,7 @@ class PeriodicProvider(Provider):
pass pass
async def loop(self) -> None: async def loop(self) -> None:
raise NotImplementedError() raise NotImplementedError
@classmethod @classmethod
async def task(cls, bar: Bar) -> None: async def task(cls, bar: Bar) -> None:

View file

@ -218,14 +218,12 @@ class MprisProvider(MirrorProvider):
) -> typing.Any: ) -> typing.Any:
if key in something.keys(): if key in something.keys():
return something[key] return something[key]
else:
return default return default
@staticmethod @staticmethod
def formatUs(ms: int) -> str: def formatUs(ms: int) -> str:
if ms < 60 * 60 * 1000000: if ms < 60 * 60 * 1000000:
return time.strftime("%M:%S", time.gmtime(ms // 1000000)) return time.strftime("%M:%S", time.gmtime(ms // 1000000))
else:
return str(datetime.timedelta(microseconds=ms)) return str(datetime.timedelta(microseconds=ms))
def findCurrentPlayer(self) -> None: def findCurrentPlayer(self) -> None:

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys
import os import os
import sys
# From https://github.com/python/cpython/blob/v3.7.0b5/Lib/site.py#L436 # From https://github.com/python/cpython/blob/v3.7.0b5/Lib/site.py#L436

View file

@ -13,8 +13,7 @@ NETWORKS_FILE = "/etc/keys/wireless_networks.json"
def wpa_cli(command: list[str]) -> list[bytes]: def wpa_cli(command: list[str]) -> list[bytes]:
command.insert(0, "wpa_cli") command.insert(0, "wpa_cli")
process = subprocess.run(command, stdout=subprocess.PIPE) process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
process.check_returncode()
lines = process.stdout.splitlines() lines = process.stdout.splitlines()
while lines[0].startswith(b"Selected interface"): while lines[0].startswith(b"Selected interface"):
lines.pop(0) lines.pop(0)

View file

@ -40,8 +40,7 @@ def list_networks() -> list[str]:
networks: list[dict[str, str | list[str] | int]] = list() networks: list[dict[str, str | list[str] | int]] = list()
for path in list_networks(): for path in list_networks():
proc = subprocess.run(["pass", path], stdout=subprocess.PIPE) proc = subprocess.run(["pass", path], stdout=subprocess.PIPE, check=True)
proc.check_returncode()
raw = proc.stdout.decode() raw = proc.stdout.decode()
split = raw.split("\n") split = raw.split("\n")