Skip to content

chore: small safety/idiomatic micro-fixes (PYI063, PLW0602, PLW1508)#169

Open
alexzhu0 wants to merge 1 commit into
FlowElement-ai:mainfrom
alexzhu0:chore/safety-microfixes-pyi063-plw0602-plw1508
Open

chore: small safety/idiomatic micro-fixes (PYI063, PLW0602, PLW1508)#169
alexzhu0 wants to merge 1 commit into
FlowElement-ai:mainfrom
alexzhu0:chore/safety-microfixes-pyi063-plw0602-plw1508

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 8, 2026

Summary

Four unrelated low-risk lint findings grouped in one PR — each is a 1-line, semantics-preserving change.

PYI063 — PEP 570 positional-only syntax (2 sites)

pydantic's model_post_init(self, __context) hook is identical in meaning to model_post_init(self, context, /). Modern form is clearer and recommended by ruff (__ prefix is legacy mypy syntax, deprecated in favor of / since 3.8).

  • adapters/vector/embeddings/config.py:44
  • llm/config.py:129

PLW0602 — drop dead global declaration (1 site)

_check_prune_cooldown only reads _last_prune_time, so the global is no-op noise. The companion _update_last_prune_time (which actually assigns) keeps its global declaration, untouched.

  • api/v1/prune/routers/get_prune_router.py:214

PLW1508 — os.getenv default must be str|None (1 site)

os.getenv("HTTP_API_PORT", 8000) passes an int as default. CPython tolerates this today but typeshed types the second arg as str | None and ruff flags it. Trivial fix: "8000" so int(...) parses it uniformly.

  • api/client.py:359

Verification

ruff check <touched files> --select PYI063,PLW0602,PLW1508
# All checks passed!
python -m py_compile <touched files>
# OK

No behavioral change in any of the four cases.


I affirm that all code in every commit of this pull request conforms to the terms of the M-flow Developer Certificate of Origin

Four unrelated low-risk lint findings, grouped in one PR:

- PYI063: replace dunder positional params with PEP 570 syntax
  pydantic's `model_post_init(self, __context)` is a hook with the same
  semantics as `model_post_init(self, context, /)`; use the modern form.
  Files: adapters/vector/embeddings/config.py, llm/config.py

- PLW0602: drop unused `global _last_prune_time` in
  `_check_prune_cooldown` (read-only function, no rebinding). The other
  helper that *does* assign keeps its `global` declaration.
  File: api/v1/prune/routers/get_prune_router.py

- PLW1508: `os.getenv(name, default)` requires str|None; passing the int
  `8000` is silently ignored if the env var is unset on some platforms
  and will raise on others. Pass "8000" so int() parses it uniformly.
  File: api/client.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant