-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Updating setup for current bootsrap - Updated depencencies - Applied linting and checks
- Loading branch information
Showing
7 changed files
with
82 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from redis import Redis | ||
from rq import Queue | ||
|
||
from api.constants import constants | ||
from redis import Redis | ||
|
||
redis_conn = Redis.from_url(constants.redis_uri, socket_timeout=500) | ||
task_queue = Queue(constants.channel_name, connection=redis_conn) |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,82 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
requires = ["hatchling", "hatch-openzim"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "nautilus-api" | ||
authors = [{ name = "Kiwix", email = "[email protected]" }] | ||
keywords = ["nautilus", "zim", "files", "webui"] | ||
requires-python = ">=3.11" | ||
description = "SaaS Web UI for nautilus" | ||
readme = "README.md" | ||
license = { text = "GPL-3.0-or-later" } | ||
classifiers = [ | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.11", | ||
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", | ||
] | ||
dependencies = [ | ||
"fastapi==0.100.0", | ||
"uvicorn[standard]==0.22.0", | ||
"httpx==0.24.1", | ||
"SQLAlchemy==2.0.18", | ||
"alembic==1.11.1", | ||
"psycopg[binary,pool]==3.1.9", | ||
"pymongo==4.4.1", | ||
"python-dateutil==2.8.2", | ||
"fastapi==0.111.0", | ||
"uvicorn[standard]==0.29.0", | ||
"httpx==0.27.0", | ||
"SQLAlchemy==2.0.30", | ||
"alembic==1.13.1", | ||
"psycopg[binary,pool]==3.1.18", | ||
"pymongo==4.7.1", | ||
"python-dateutil==2.9.0.post0", | ||
"kiwixstorage==0.8.3", | ||
"python-multipart==0.0.6", | ||
"zimscraperlib==3.1.1", | ||
"python-multipart==0.0.9", | ||
"zimscraperlib==3.3.2", | ||
"humanfriendly==10.0", | ||
"rq==1.15.1", | ||
"rq==1.16.2", | ||
] | ||
dynamic = ["version"] | ||
dynamic = ["authors", "license", "version", "urls"] | ||
|
||
[project.optional-dependencies] | ||
scripts = ["invoke==2.1.3"] | ||
lint = ["black==23.3.0", "ruff==0.0.272"] | ||
test = ["pytest==7.3.1", "pytest-mock==3.11.1", "coverage==7.2.7"] | ||
check = ["pyright==1.1.317"] | ||
scripts = [ | ||
"invoke==2.2.0", | ||
] | ||
lint = [ | ||
"black==24.4.2", | ||
"ruff==0.4.3", | ||
] | ||
check = [ | ||
"pyright==1.1.361", | ||
] | ||
test = [ | ||
"pytest==8.2.0", | ||
"coverage==7.5.1", | ||
] | ||
dev = [ | ||
"debugpy==1.6.7", | ||
"pre-commit==3.7.0", | ||
"nautilus-api[scripts]", | ||
"nautilus-api[lint]", | ||
"nautilus-api[test]", | ||
"nautilus-api[check]", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/openzim/nautilus-webui" | ||
Donate = "https://www.kiwix.org/en/support-us/" | ||
|
||
[project.scripts] | ||
serve = "api.entrypoint:run" | ||
|
||
[tool.hatch.version] | ||
path = "api/__about__.py" | ||
|
||
[tool.hatch.build] | ||
exclude = ["/.github"] | ||
packages = ["api"] | ||
|
||
[tool.hatch.envs.default] | ||
features = ["dev"] | ||
|
||
[tool.hatch.envs.default.env-vars] | ||
POSTGRES_URI = "postgresql+psycopg://nautilus:nautilus@localhost/nautilus" | ||
|
||
[tool.hatch.envs.test] | ||
features = ["scripts", "test"] | ||
|
||
[[tool.hatch.envs.test.matrix]] | ||
python = ["3.11"] | ||
python = ["3.10", "3.11"] | ||
|
||
[tool.hatch.envs.test.scripts] | ||
run = "inv test --args '{args}'" | ||
run-cov = "inv test-cov --args '{args}'" | ||
report-cov = "inv report-cov" | ||
coverage = "inv coverage --args '{args}'" | ||
html = "inv coverage --html --args '{args}'" | ||
|
||
[tool.hatch.envs.lint] | ||
template = "lint" | ||
|
@@ -90,7 +92,7 @@ fix-ruff = "inv fix-ruff --args '{args}'" | |
fixall = "inv fixall --args '{args}'" | ||
|
||
[tool.hatch.envs.check] | ||
features = ["scripts", "test"] | ||
features = ["scripts", "check"] | ||
|
||
[tool.hatch.envs.check.scripts] | ||
pyright = "inv check-pyright --args '{args}'" | ||
|
@@ -103,95 +105,96 @@ target-version = ['py310'] | |
[tool.ruff] | ||
target-version = "py311" | ||
line-length = 88 | ||
src = ["api", "tests", "migrations"] | ||
src = ["src"] | ||
|
||
[tool.ruff.lint] | ||
select = [ | ||
"A", # flake8-builtins | ||
"A", # flake8-builtins | ||
# "ANN", # flake8-annotations | ||
"ARG", # flake8-unused-arguments | ||
"ARG", # flake8-unused-arguments | ||
# "ASYNC", # flake8-async | ||
"B", # flake8-bugbear | ||
"B", # flake8-bugbear | ||
# "BLE", # flake8-blind-except | ||
"C4", # flake8-comprehensions | ||
"C90", # mccabe | ||
"C90", # mccabe | ||
# "COM", # flake8-commas | ||
# "D", # pydocstyle | ||
# "DJ", # flake8-django | ||
"DTZ", # flake8-datetimez | ||
"E", # pycodestyle (default) | ||
"DTZ", # flake8-datetimez | ||
"E", # pycodestyle (default) | ||
"EM", # flake8-errmsg | ||
# "ERA", # eradicate | ||
# "EXE", # flake8-executable | ||
"F", # Pyflakes (default) | ||
"F", # Pyflakes (default) | ||
# "FA", # flake8-future-annotations | ||
"FBT", # flake8-boolean-trap | ||
"FBT", # flake8-boolean-trap | ||
# "FLY", # flynt | ||
# "G", # flake8-logging-format | ||
"I", # isort | ||
"ICN", # flake8-import-conventions | ||
"I", # isort | ||
"ICN", # flake8-import-conventions | ||
# "INP", # flake8-no-pep420 | ||
# "INT", # flake8-gettext | ||
"ISC", # flake8-implicit-str-concat | ||
"N", # pep8-naming | ||
"ISC", # flake8-implicit-str-concat | ||
"N", # pep8-naming | ||
# "NPY", # NumPy-specific rules | ||
# "PD", # pandas-vet | ||
# "PGH", # pygrep-hooks | ||
# "PIE", # flake8-pie | ||
# "PL", # Pylint | ||
"PLC", # Pylint: Convention | ||
"PLE", # Pylint: Error | ||
"PLR", # Pylint: Refactor | ||
"PLW", # Pylint: Warning | ||
"PLC", # Pylint: Convention | ||
"PLE", # Pylint: Error | ||
"PLR", # Pylint: Refactor | ||
"PLW", # Pylint: Warning | ||
# "PT", # flake8-pytest-style | ||
# "PTH", # flake8-use-pathlib | ||
# "PYI", # flake8-pyi | ||
"Q", # flake8-quotes | ||
"Q", # flake8-quotes | ||
# "RET", # flake8-return | ||
# "RSE", # flake8-raise | ||
"RUF", # Ruff-specific rules | ||
"S", # flake8-bandit | ||
"RUF", # Ruff-specific rules | ||
"S", # flake8-bandit | ||
# "SIM", # flake8-simplify | ||
# "SLF", # flake8-self | ||
"T10", # flake8-debugger | ||
"T20", # flake8-print | ||
"T10", # flake8-debugger | ||
"T20", # flake8-print | ||
# "TCH", # flake8-type-checking | ||
# "TD", # flake8-todos | ||
"TID", # flake8-tidy-imports | ||
"TID", # flake8-tidy-imports | ||
# "TRY", # tryceratops | ||
"UP", # pyupgrade | ||
"W", # pycodestyle | ||
"YTT", # flake8-2020 | ||
"W", # pycodestyle | ||
"YTT", # flake8-2020 | ||
] | ||
ignore = [ | ||
# We will use variable names such as id in the database model. Excluding this rule prevents useless warnings | ||
"A003", | ||
# Exclude this rule to eliminate warnings about calls to Depends in FastAPI | ||
"B008", | ||
# Allow non-abstract empty methods in abstract base classes | ||
"B027", | ||
# Remove flake8-errmsg since we consider they bloat the code and provide limited value | ||
"EM", | ||
# Allow boolean positional values in function calls, like `dict.get(... True)` | ||
"FBT003", | ||
# Ignore checks for possible passwords | ||
"S105", | ||
"S106", | ||
"S107", | ||
"S105", "S106", "S107", | ||
# Ignore warnings on subprocess.run / popen | ||
"S603", | ||
# Ignore complexity | ||
"C901", | ||
"PLR0911", | ||
"PLR0912", | ||
"PLR0913", | ||
"PLR0915", | ||
"C901", "PLR0911", "PLR0912", "PLR0913", "PLR0915", | ||
] | ||
unfixable = [ | ||
# Don't touch unused imports | ||
"F401", | ||
] | ||
|
||
[tool.ruff.isort] | ||
[tool.ruff.lint.isort] | ||
known-first-party = ["api"] | ||
|
||
[tool.ruff.flake8-tidy-imports] | ||
[tool.ruff.lint.flake8-bugbear] | ||
# add exceptions to B008 for fastapi. | ||
extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"] | ||
|
||
[tool.ruff.lint.flake8-tidy-imports] | ||
ban-relative-imports = "all" | ||
|
||
[tool.ruff.per-file-ignores] | ||
[tool.ruff.lint.per-file-ignores] | ||
# Tests can use magic values, assertions, and relative imports | ||
"tests/**/*" = ["PLR2004", "S101", "TID252"] | ||
|
||
|
@@ -201,7 +204,8 @@ testpaths = ["tests"] | |
pythonpath = [".", "src"] | ||
|
||
[tool.coverage.paths] | ||
source = ["api"] | ||
api = ["api"] | ||
tests = ["tests"] | ||
|
||
[tool.coverage.run] | ||
source_pkgs = ["api"] | ||
|
@@ -218,3 +222,4 @@ exclude = [".env/**", ".venv/**"] | |
extraPaths = ["src"] | ||
pythonVersion = "3.11" | ||
typeCheckingMode = "basic" | ||
disableBytesTypePromotions = true |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: "3.1" | ||
|
||
services: | ||
database: | ||
image: postgres:15.3-bullseye | ||
|