Skip to content

fix: resolve python formatting failure and ignore local memories - #62

Merged
Archmonger merged 1 commit into
mainfrom
fix-python-formatting-tc001
Nov 15, 2026
Merged

Archmonger merged 1 commit into
mainfrom
fix-python-formatting-tc001

Conversation

@Archmonger

Copy link
Copy Markdown
Contributor

Description

Resolves the python-formatting job failure in run 43672620290, which ran hatch fmt src tests --check and failed with:

TC001 Move application import `reactpy_router.types.RouteState` into a type-checking block
  --> src/reactpy_router/hooks.py:9:34
   |
 9 | from reactpy_router.types import RouteState
   |                                  ^^^^^^^^^^
   |
help: Move into type-checking block

Root cause

hooks.py starts with from __future__ import annotations, so every annotation in that module is a string and is never evaluated at runtime. RouteState is only used in annotations there (_route_state_context and _use_route_state's return type), which makes the runtime import dead weight and triggers ruff's TC001.

Fix

  • Move the RouteState import into the existing TYPE_CHECKING block in src/reactpy_router/hooks.py.
  • src/reactpy_router/routers.py instantiates RouteState(...) at runtime, so it now imports it directly from reactpy_router.types instead of re-exporting it through hooks. That keeps a single, correct source of truth for the symbol and avoids relying on an incidental re-export.
  • Add a memories/* entry to .gitignore so local LLM artifacts are not committed.

Verification

  • hatch fmt src tests --check — All checks passed! and 13 files already formatted
  • Also clean under the bundled ruff 0.13.2 (the CI version) as well as ruff 0.17.5
  • hatch run python:type_check — 0 errors, 0 warnings, 0 informations
  • hatch test -py=3.13 --headless — 30 passed

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

CI's `hatch fmt src tests --check` failed with:

    TC001 Move application import `reactpy_router.types.RouteState` into a type-checking block
      --> src/reactpy_router/hooks.py:9:34

`RouteState` is only referenced from annotations in `hooks.py`, where
`from __future__ import annotations` makes those annotations strings, so the
import belongs in the `TYPE_CHECKING` block. `routers.py` constructs
`RouteState(...)` at runtime, so it now imports it directly from
`reactpy_router.types` rather than re-exporting it through `hooks`.

Also adds a `memories/*` entry to `.gitignore` so local LLM artifacts stay
out of the repository.
@Archmonger
Archmonger requested a review from a team as a code owner November 15, 2026 03:42
@Archmonger
Archmonger merged commit 502f9dc into main Nov 15, 2026
9 checks passed
@Archmonger
Archmonger deleted the fix-python-formatting-tc001 branch November 15, 2026 05:28
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