**Replace Flake8 with Ruff, refactor type hints, and enhance archive processing logic**

- Removed `flake8` and `flake8-annotations` from dependencies, replaced by `ruff` for linting.
- Introduced cleaner type hinting and modern Python annotations (PEP 604 style) across multiple modules.
- Moved archive processing to a dedicated helper (`comic.archives`) for improved maintainability.
- Updated and simplified logic for archive file retrieval, directory cleaning, and user access validation.
- Improved error handling and added support for user classification restrictions in API responses.
This commit is contained in:
ajurna committed 2026-10-13 12:07:47 +01:00
1 parent 1148f4072b
commit a7e9bd0743
16 files changed
+553 -4

No files matched your search

+4
View File
@@ -247,6 +247,10 @@ SIMPLE_JWT = {
'ISSUER': 'cbwebreader',
}
# Renderer formats no longer include a leading dot, so the URL pattern in
# cbreader/urls.py matches the dot separately. See cbreader/urls.py.
SWAGGER_USE_COMPAT_RENDERERS = False
FRONTEND_DIR = os.path.join(BASE_DIR, 'frontend')
TEMPLATES = [
+24
View File
@@ -0,0 +1,24 @@
"""Settings used by the test suite.
In-memory SQLite so the tests do not need a running Postgres, and a scratch comic
volume that the fixtures fill with generated archives.
"""
import os
from pathlib import Path
from cbreader.settings.base import * # noqa: F403
from cbreader.settings.base import BASE_DIR
SECRET_KEY = 'test-secret-key'
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
COMIC_BOOK_VOLUME = Path(os.environ.get('COMIC_TEST_VOLUME', BASE_DIR / 'test_comics'))
MEDIA_ROOT = BASE_DIR / 'test_media'
+1 -1
View File
@@ -58,7 +58,7 @@ router.register(r'initial_setup', rest.InitialSetup, basename='initial_setup')
urlpatterns = [
path('admin/', admin.site.urls),
path("feed/<user_selector>/", feeds.RecentComicsAPI()),
re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger\.(?P<format>json|yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
re_path(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),