Skip to content

Conversation

@tbhb
Copy link
Contributor

@tbhb tbhb commented Jan 1, 2026

Summary

  • Create new _types.py module containing all TypeAlias definitions for JSON and key types
  • Remove # pyright: reportImportCycles=false pragma from _exceptions.py
  • Update _json.py and _keys.py to import types from _types.py and re-export for backwards compatibility

Problem

Circular import between:

  • _exceptions.py → needs JSONObject and Key for ConflictError type annotations
  • _json.py → needs ParseError, LimitError from _exceptions.py
  • _keys.py → needs InvalidKeyError, LimitError from _exceptions.py

Solution

Extract pure type aliases to _types.py with no dependencies on other JSONLT modules, breaking the cycle.

Test plan

  • Type checking passes: uv run basedpyright src/jsonlt/
  • All tests pass: uv run pytest tests/
  • Package imports cleanly without warnings

Move JSONObject, JSONValue, JSONArray, JSONPrimitive, Key, KeyElement,
and KeySpecifier type aliases to a new _types.py module. This breaks
the circular import between _exceptions.py, _json.py, and _keys.py.

The cycle existed because _exceptions.py needed type annotations from
_json.py and _keys.py, but those modules import exceptions.
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 1, 2026

CodSpeed Performance Report

Merging #13 will not alter performance

Comparing fix-import-cycle (137c151) with main (48ed64a)

Summary

✅ 173 untouched
⏩ 1 skipped1

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@tbhb tbhb merged commit 3453e5d into main Jan 1, 2026
30 checks passed
@tbhb tbhb deleted the fix-import-cycle branch January 1, 2026 23:55
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.

2 participants