Skip to content

Commit 0b4f805

Browse files
Isaac SpringerIsaac Springer
authored andcommitted
fix: pylint errors
1 parent f518f8f commit 0b4f805

5 files changed

Lines changed: 34 additions & 21 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,5 @@ cython_debug/
179179
.cocoindex_code/
180180
.claude/
181181
.claude-flow/
182-
docs/superpowers/
182+
docs/superpowers/
183+
.swarm/

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- gitnexus:start -->
22
# GitNexus — Code Intelligence
33

4-
This project is indexed by GitNexus as **TinySteno** (238 symbols, 594 relationships, 20 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
4+
This project is indexed by GitNexus as **TinySteno** (270 symbols, 711 relationships, 21 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
55

66
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
77

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- gitnexus:start -->
22
# GitNexus — Code Intelligence
33

4-
This project is indexed by GitNexus as **TinySteno** (238 symbols, 594 relationships, 20 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
4+
This project is indexed by GitNexus as **TinySteno** (270 symbols, 711 relationships, 21 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
55

66
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
77

tinysteno/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ def _process_audio( # pylint: disable=too-many-arguments,too-many-positional-ar
163163
title_future = None
164164
tags_future = None
165165

166-
if (config.get("auto_title") or config.get("auto_tags")) and orchestrator and first_string_value:
166+
wants_llm_metadata = config.get("auto_title") or config.get("auto_tags")
167+
if wants_llm_metadata and orchestrator and first_string_value:
167168
print("Generating title and tags...")
168169
with ThreadPoolExecutor(max_workers=2) as executor:
169170
if config.get("auto_title"):

tinysteno/recorder.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
try:
1515
import sounddevice as sd
1616
except Exception: # pragma: no cover
17-
sd = None # type: ignore
17+
sd = None # type: ignore # pylint: disable=invalid-name
1818

1919

2020
class AudioRecorder:
@@ -179,12 +179,12 @@ def start(self, name: Optional[str] = None) -> str:
179179
fd, mic_path = tempfile.mkstemp(suffix=".f32")
180180
os.close(fd)
181181
self._mic_raw_path = Path(mic_path)
182-
self._mic_fh = open(mic_path, "wb")
182+
self._mic_fh = open(mic_path, "wb") # pylint: disable=consider-using-with
183183

184184
fd, lb_path = tempfile.mkstemp(suffix=".f32")
185185
os.close(fd)
186186
self._loopback_raw_path = Path(lb_path)
187-
self._loopback_fh = open(lb_path, "wb")
187+
self._loopback_fh = open(lb_path, "wb") # pylint: disable=consider-using-with
188188

189189
try:
190190
self._audio_interface = sd.InputStream(
@@ -227,7 +227,7 @@ def _start_macos_loopback(self) -> bool:
227227

228228
self._macos_loopback = MacOSLoopback(
229229
sample_rate=self.sample_rate,
230-
callback=lambda indata: self._write_loopback_frame(indata),
230+
callback=self._write_loopback_frame,
231231
)
232232
self._macos_loopback.start()
233233
return True
@@ -290,19 +290,9 @@ def stop(self) -> bool:
290290
ch = self._mic_channels_written
291291
mic_data = raw.reshape(-1, ch) if ch > 1 else raw.reshape(-1, 1)
292292

293-
if self._has_loopback and loopback_raw_bytes:
294-
lb_raw = np.frombuffer(loopback_raw_bytes, dtype=np.float32)
295-
lbch = self._loopback_channels_written
296-
lb_data = lb_raw.reshape(-1, lbch) if lbch > 1 else lb_raw.reshape(-1, 1)
297-
if loopback_sr and abs(loopback_sr - self.sample_rate) > 1:
298-
from scipy.signal import resample as scipy_resample
299-
n_out = int(round(len(lb_data) * self.sample_rate / loopback_sr))
300-
lb_data = scipy_resample(lb_data.squeeze(), n_out).astype(np.float32).reshape(-1, 1)
301-
audio_data = self._mix_stereo(mic_data, lb_data)
302-
out_channels = 2
303-
else:
304-
audio_data = mic_data
305-
out_channels = ch
293+
audio_data, out_channels = self._build_audio_data(
294+
mic_data, ch, loopback_raw_bytes, loopback_sr
295+
)
306296

307297
max_val = np.max(np.abs(audio_data))
308298
if max_val > 0:
@@ -339,6 +329,27 @@ def _cleanup_temp_files(self) -> None:
339329
self._loopback_raw_path.unlink(missing_ok=True)
340330
self._loopback_raw_path = None
341331

332+
def _build_audio_data(
333+
self,
334+
mic_data: np.ndarray,
335+
mic_ch: int,
336+
loopback_raw_bytes: bytes,
337+
loopback_sr: Optional[int],
338+
) -> tuple[np.ndarray, int]:
339+
"""Mix mic and loopback raw bytes into final audio array."""
340+
if not (self._has_loopback and loopback_raw_bytes):
341+
return mic_data, mic_ch
342+
343+
from scipy.signal import resample as scipy_resample # pylint: disable=import-outside-toplevel
344+
345+
lb_raw = np.frombuffer(loopback_raw_bytes, dtype=np.float32)
346+
lbch = self._loopback_channels_written
347+
lb_data = lb_raw.reshape(-1, lbch) if lbch > 1 else lb_raw.reshape(-1, 1)
348+
if loopback_sr and abs(loopback_sr - self.sample_rate) > 1:
349+
n_out = int(round(len(lb_data) * self.sample_rate / loopback_sr))
350+
lb_data = scipy_resample(lb_data.squeeze(), n_out).astype(np.float32).reshape(-1, 1)
351+
return self._mix_stereo(mic_data, lb_data), 2
352+
342353
def _mix_stereo(self, mic: np.ndarray, loopback: np.ndarray) -> np.ndarray:
343354
"""Combine mic and loopback into a stereo array [n, 2] (L=mic, R=loopback)."""
344355
# Reduce to mono

0 commit comments

Comments
 (0)