Skip to content

Commit 895849e

Browse files
committed
Fix lint
1 parent 4983db7 commit 895849e

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

irctest/basecontrollers.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
import sys
1212
import tempfile
1313
import textwrap
14-
import time
1514
import threading
15+
import time
1616
from typing import (
1717
IO,
1818
Any,
@@ -150,33 +150,42 @@ def kill(self) -> None:
150150
self._own_ports.remove((hostname, port))
151151

152152
def execute(
153-
self, command: Sequence[Union[str, Path]], proc_name: Optional[str], **kwargs: Any
153+
self,
154+
command: Sequence[Union[str, Path]],
155+
proc_name: Optional[str] = None,
156+
**kwargs: Any,
154157
) -> subprocess.Popen:
155158
output_to = None if self.debug_mode else subprocess.DEVNULL
156-
proc_name = proc_name or command[0]
159+
proc_name = proc_name or str(command[0])
157160
kwargs.setdefault("stdout", output_to)
158161
kwargs.setdefault("stderr", output_to)
159162
stream_stdout = stream_stderr = None
160163
if kwargs["stdout"] in (None, subprocess.STDOUT):
161164
kwargs["stdout"] = subprocess.PIPE
162-
def stream_stdout():
165+
166+
def stream_stdout() -> None:
167+
assert proc.stdout is not None # for mypy
163168
for line in proc.stdout:
164169
prefix = f"{time.time():.3f} {proc_name} ".encode()
165170
try:
166171
sys.stdout.buffer.write(prefix + line)
167172
except ValueError:
168173
# "I/O operation on closed file"
169174
pass
175+
170176
if kwargs["stderr"] in (subprocess.STDOUT, None):
171177
kwargs["stdout"] = subprocess.PIPE
172-
def stream_stderr():
173-
for line in proc.stdout:
178+
179+
def stream_stderr() -> None:
180+
assert proc.stderr is not None # for mypy
181+
for line in proc.stderr:
174182
prefix = f"{time.time():.3f} {proc_name} ".encode()
175183
try:
176184
sys.stdout.buffer.write(prefix + line)
177185
except ValueError:
178186
# "I/O operation on closed file"
179187
pass
188+
180189
proc = subprocess.Popen(command, **kwargs)
181190
if stream_stdout is not None:
182191
threading.Thread(target=stream_stdout, name="stream_stdout").start()

irctest/controllers/sable.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ def certs_dir() -> Path:
8585
certs_dir = tempfile.TemporaryDirectory()
8686
(Path(certs_dir.name) / "gen_certs.sh").write_text(GEN_CERTS)
8787
subprocess.run(
88-
["bash", "gen_certs.sh", "My.Little.Server", "My.Little.History", "My.Little.Services"],
88+
[
89+
"bash",
90+
"gen_certs.sh",
91+
"My.Little.Server",
92+
"My.Little.History",
93+
"My.Little.Services",
94+
],
8995
cwd=certs_dir.name,
9096
check=True,
9197
)
@@ -585,7 +591,9 @@ class SableHistoryController(BaseServicesController):
585591
def run(self, protocol: str, server_hostname: str, server_port: int) -> None:
586592
assert protocol == "sable"
587593
assert self.server_controller.directory is not None
588-
history_db_url=os.environ.get("PIFPAF_POSTGRESQL_URL") or os.environ.get("IRCTEST_POSTGRESQL_URL")
594+
history_db_url = os.environ.get("PIFPAF_POSTGRESQL_URL") or os.environ.get(
595+
"IRCTEST_POSTGRESQL_URL"
596+
)
589597
assert history_db_url, (
590598
"Cannot find a postgresql database to use as backend for sable_history. "
591599
"Either set the IRCTEST_POSTGRESQL_URL env var to a libpq URL, or "
@@ -594,10 +602,9 @@ def run(self, protocol: str, server_hostname: str, server_port: int) -> None:
594602
)
595603

596604
with self.server_controller.open_file("configs/history_server.conf") as fd:
597-
fd.write(HISTORY_SERVER_CONFIG % {
598-
**self.server_controller.template_vars,
599-
"history_db_url": history_db_url,
600-
})
605+
vals = dict(self.server_controller.template_vars)
606+
vals["history_db_url"] = history_db_url
607+
fd.write(HISTORY_SERVER_CONFIG % vals)
601608

602609
self.proc = self.execute(
603610
[

0 commit comments

Comments
 (0)