Repository navigation
Conversation
added 7 commits
September 18, 2026 09:35
auth_service, auth_strategy, cache_handler, cache_service, crud_sync, crud_async, queryset, http_dispatcher, middleware_pipeline and route_builder are leftovers of an earlier attempt to split lightapi.py into classes. The split was never wired: register() still builds its handlers through handler_factory, and RestEndpoint still owns the CRUD. No file in the package, tests, examples or docs imports any of them, none is exported from lightapi/__init__.py, and no open PR touches them. queryset.py was only used by the two crud_* modules. They had already drifted from the live code, so reading them gave the wrong picture of how a request is handled. pyproject.toml loses only the mypy override entries that named the deleted files. swagger.py is also unimported but stays: .cursorrules lists it as frozen. Behaviour is unchanged: 327 passed, 1 xfailed, 2 xpassed, same as before the change. ruff, ruff format and mypy are clean.
swagger.py (SwaggerGenerator plus two route functions, 323 lines) is not imported by the package, tests, examples or docs, and no route ever serves it. docs/api-reference/swagger.md already tells users that v2 ships no built-in Swagger UI or OpenAPI endpoint and points them to Starlette tooling, so the module contradicted the documented behaviour. It was kept out of the previous commit because .cursorrules lists it as frozen. That list dates from 2026-03-05 and is dropped in the next commit. Tests are unchanged: 327 passed, 1 xfailed, 2 xpassed.
The list was written on 2026-03-05 for the 1-v2-full-refactor branch and never edited again. The files it froze kept changing anyway: 14 commits to lightapi.py since then, 4 to auth.py, 3 to cache.py. An agent that reads the file is told not to touch code the project itself edits every month, so the rule only blocks work and protects nothing. Removes the section and the three inline "FROZEN" notes that repeated it. The rest of the file is untouched.
When the request handlers moved to handler_factory.py the originals stayed behind: LightApi._make_collection_handler, _make_detail_handler and nine module functions (_read_body, _check_auth, the two middleware runners, the cache helpers, _wrap_dict_response). register() has used handler_factory.make_* since then, so the only callers of the old functions were each other. The copies had drifted. The dead _check_auth treated AllowAny differently from the live auth_checker.check_auth, so anyone reading the main file read the wrong rule. _validate_async_dependencies stays: run() uses it and a test imports it. Nine imports that only served the dead code go with it. The handlers doc now names the functions that really build the routes. Tests are unchanged: 327 passed, 1 xfailed, 2 xpassed.
Each of these is referenced only by itself or by another item in this list. Nothing in the package, tests, examples or docs uses them, and none is exported from lightapi/__init__.py: - cache.py: CacheBackend, CacheManager, _cache_manager, _get_redis. The live cache path is RedisCacheBackend behind get_cached, set_cached and invalidate_cache_prefix. RedisCache and BaseCache stay: they are public. - schema.py: SchemaHelper (a class that only forwarded to the four module functions), register_column_type with its empty registry, and _strip_lightapi_kwargs. - session_manager.py: EngineProtocol, AsyncEngineProtocol, EngineType, LoginValidator, clear_test_registries, and the SessionManager members is_async, get_registry_and_metadata, session, async_session, dispose. CRUD code opens its own sessions, so these were never reached. The docstrings now say what the class really does. - pagination.py: PaginatorProtocol and PaginatorFactory. The protocol described a wrap() signature that neither paginator has. - exceptions.py: MissingHandlerImplementationError. Tests are unchanged: 327 passed, 1 xfailed, 2 xpassed.
- constants.py: the HttpMethod enum (only the deleted http_dispatcher used it; the live HttpMethod is the mixin namespace in methods.py) and ten constants nothing reads: RESPONSE_KEY_ERROR, RESPONSE_KEY_ALLOWED_METHODS, RESERVED_JWT_CLAIMS, the three DEFAULT_RATE_LIMIT_*, CLEANUP_INTERVAL, DEFAULT_MODE, VALID_MODES and DEFAULT_AUTH_PATH. Checked against lightapi/, tests/, examples/ and docs/. - config.py: Config.update, Authentication.permission_value, and an Authentication.__post_init__ whose body was `pass`. No caller, and not shown in any doc or example. - rest.py: _test_isolation_table_name was written on every endpoint class and never read. The try/except around `from sqlalchemy import Uuid` could never fail: the dependency floor is SQLAlchemy 2.0.30 and Uuid is present there (checked on 2.0.30 and 2.0.40), so the PG_UUID fallback was unreachable. Tests are unchanged: 327 passed, 1 xfailed, 2 xpassed.
pyproject.toml still carried a ruff per-file-ignore and a mypy ignore_errors entry for base_endpoint, database, handlers and models. Those four files were deleted in e2faf25 ("Remove legacy features and fix documentation"), so the entries matched nothing. Only the [tool.ruff] and [tool.mypy] tables change. ruff and mypy give the same result as before.
This was referenced Sep 18, 2026
Closed
Closed
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes code that nothing uses. The package goes from 7,516 to 5,077 lines (45 to 34 files). Behaviour does not change.
One commit per step, so each can be reverted alone:
auth_service,auth_strategy,cache_handler,cache_service,crud_sync,crud_async,queryset,http_dispatcher,middleware_pipeline,route_builder.swagger.py, also unimported.docs/api-reference/swagger.mdalready says v2 has no built-in Swagger UI..cursorrules: drops the FROZEN list from 2026-03-05. The files it froze got 25 commits since that date, 14 of them inlightapi.py.lightapi.py: the old copies of the request handlers (_make_collection_handler,_make_detail_handlerand nine helper functions).register()has usedhandler_factoryfor a while, so these only called each other. 910 lines down to 612.cache.py,schema.py,session_manager.py,pagination.pyandexceptions.py.constants.py: an unusedHttpMethodenum and ten unused constants.config.py:Config.update,Authentication.permission_valueand an empty__post_init__.rest.py: an attribute that was written and never read, and atry/except ImportErroraroundsqlalchemy.Uuidthat could not fail.pyproject.toml: lint and type-check entries for files that no longer exist. Project metadata is untouched.Why
Most of this is left over from an earlier try at splitting
lightapi.pyinto classes. The split was never wired in, and the copies drifted. For example the dead_check_authinlightapi.pytreatedAllowAnydifferently from the liveauth_checker.check_auth, so reading the main file gave the wrong rule.How I checked each thing is dead
lightapi/,tests/,examples/anddocs/. Each removed name was used only by itself or by another removed name.lightapi/__init__.py, and none appears in the docs, README, examples or changelog.sqlalchemy.Uuidexists on 2.0.30, the lowest versionpyproject.tomlallows, and on 2.0.40. Checked both.Not checked: code outside this repo. The removed modules imported without error before, and
Config.update,Authentication.permission_valueand theSessionManagermethodssession,async_session,disposewere public names, even if undocumented. Code that uses any of them directly would break.Checks
All run on my machine. The test workflow does not run for PRs into
dev, only GitGuardian did.pytest: 327 passed, 1 xfailed, 2 xpassed. Same asdev.lightapi/: 59% ondev(3,399 statements, 1,390 missed), 82% here (2,343 and 429). Same tests, less untested code. Still under the 90% target.ruff check,ruff format --check,mypy: clean.