Skip to content

Commit

Permalink
Improve some type hinting
Browse files Browse the repository at this point in the history
  • Loading branch information
le717 committed Jun 8, 2024
1 parent 62a698e commit b59174e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
16 changes: 15 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@ httpx = "^0.27.0"
mypy = "^1.10.0"
pytest = "^8.2.2"
ruff = "^0.4.8"
types-flask-cors = "^4.0.0.20240523"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.mypy]
[[tool.mypy.overrides]]
module = ["flask_smorest", "sys_vars", "sqlalchemy"]
ignore_missing_imports = true

[tool.ruff]
target-version = "py311"
line-length = 100
Expand Down
4 changes: 2 additions & 2 deletions src/views/linkrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class LinkRotCheck(MethodView):
@linkrot.arguments(models.AuthKey, location="query", as_kwargs=True)
@linkrot.response(200, models.RotResult(many=True))
def post(self, **kwargs: Any) -> list[models.RotResult]:
def post(self, **kwargs: Any) -> list[db.RotResult]:
"""Check all links in the ring for link rot."""
del kwargs["auth_key"]
return db.check_all()
Expand All @@ -24,7 +24,7 @@ class LinkRotSingleCheck(MethodView):
@linkrot.arguments(models.WebLinkId, location="path", as_kwargs=True)
@linkrot.response(200, models.RotResult)
@linkrot.alt_response(404, schema=models.HttpError)
def post(self, **kwargs: Any) -> models.RotResult:
def post(self, **kwargs: Any) -> db.RotResult | None:
"""Check a single link in the ring for link rot."""
del kwargs["auth_key"]
if (result := db.check_one(str(kwargs["id"]))) is None:
Expand Down
4 changes: 2 additions & 2 deletions src/views/root.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any
from typing import Any, Sequence
from uuid import UUID

from flask import abort, request
Expand All @@ -13,7 +13,7 @@
class WebRing(MethodView):
@root.arguments(models.WebLinkGet, location="query", as_kwargs=True)
@root.response(200, models.WebLink(many=True))
def get(self, **kwargs: Any) -> list[models.WebLink]:
def get(self, **kwargs: Any) -> Sequence[models.WebLink]:
"""Fetch webring items.
Provide the appropriate query string arguments to
Expand Down

0 comments on commit b59174e

Please sign in to comment.