diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 90f2120..af53c62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,9 @@ jobs: - name: Run ruff format check run: uv run ruff format --check flickr_api/ + - name: Run mypy + run: uv run mypy flickr_api/ + test: runs-on: ubuntu-latest strategy: diff --git a/flickr_api/method_call.py b/flickr_api/method_call.py index 10a13b1..3a0ccf8 100644 --- a/flickr_api/method_call.py +++ b/flickr_api/method_call.py @@ -165,8 +165,12 @@ def get_rate_limit_status() -> dict[str, Any]: - interval_seconds: float - Minimum time between requests (0.0 if disabled) - last_request_time: float | None - Timestamp of last request """ - enabled = _RATE_LIMIT_REQUESTS_PER_HOUR is not None - interval = 3600.0 / _RATE_LIMIT_REQUESTS_PER_HOUR if enabled else 0.0 + if _RATE_LIMIT_REQUESTS_PER_HOUR is not None: + enabled = True + interval = 3600.0 / _RATE_LIMIT_REQUESTS_PER_HOUR + else: + enabled = False + interval = 0.0 return { "enabled": enabled, "requests_per_hour": _RATE_LIMIT_REQUESTS_PER_HOUR, diff --git a/pyproject.toml b/pyproject.toml index d5d1177..a21d333 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,3 +48,17 @@ testpaths = ["test"] [tool.ruff] line-length = 100 + +[tool.mypy] +python_version = "3.10" + +# Third-party libraries without type information. `requests_oauthlib` ships no +# stubs, and `PIL` (Pillow) is an optional runtime dependency that is not +# installed by default. +[[tool.mypy.overrides]] +module = [ + "requests_oauthlib", + "PIL", + "PIL.*", +] +ignore_missing_imports = true