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):
raise FileNotFoundError(f"Flake not found: {flakeUri}")
# 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)
p.check_returncode()
# for each dependency
for dep_name, dep in deps.items():
dep_url = dep["url"]
@ -47,8 +46,7 @@ def process_flake(flakeUri: str) -> None:
"update",
dep_name,
]
p = subprocess.run(cmd, cwd=flakeUri)
p.check_returncode()
p = subprocess.run(cmd, cwd=flakeUri, check=True)
if __name__ == "__main__":

View file

@ -133,7 +133,7 @@ class Desk:
self._reset_estimations()
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:
raw = self._get(4)
@ -170,9 +170,8 @@ class Desk:
if start_val < self.destination:
end_val = start_val + delta_u
return min(end_val, self.destination)
else:
end_val = start_val - delta_u
return max(end_val, self.destination)
end_val = start_val - delta_u
return max(end_val, self.destination)
self.est_value_bot = move_closer(self.est_value_bot)
self.est_value_top = move_closer(self.est_value_top)
@ -260,8 +259,7 @@ class Desk:
def get_height(self) -> float | None:
if self.est_value is None:
return None
else:
return self._unitToCm(self.est_value)
return self._unitToCm(self.est_value)
if __name__ == "__main__":

View file

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

View file

@ -218,15 +218,13 @@ class MprisProvider(MirrorProvider):
) -> typing.Any:
if key in something.keys():
return something[key]
else:
return default
return default
@staticmethod
def formatUs(ms: int) -> str:
if ms < 60 * 60 * 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:
for name in [self.playerctldName] + self.manager.props.player_names:

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python3
import sys
import os
import sys
# 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]:
command.insert(0, "wpa_cli")
process = subprocess.run(command, stdout=subprocess.PIPE)
process.check_returncode()
process = subprocess.run(command, stdout=subprocess.PIPE, check=True)
lines = process.stdout.splitlines()
while lines[0].startswith(b"Selected interface"):
lines.pop(0)

View file

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