Skip to content

Commit

Permalink
⏫ Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
spapanik committed Oct 18, 2024
1 parent ca9c4dd commit 4349cab
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cookbook.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$globals:
shell: bash
version: "7.0"
version: "8.1"
vars:
p_sync: --sync

Expand All @@ -26,7 +26,7 @@ lint:
- install
commands:
- black --check .
- p check
- p check --lockfile
- ruff check .
- mypy .

Expand Down
33 changes: 20 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"phosphorus>=0.3",
"phosphorus>=0.5",
]
build-backend = "phosphorus.construction.api"

Expand All @@ -23,6 +23,8 @@ keywords = [
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: BSD License",
"Intended Audience :: Developers",
]

Expand All @@ -40,25 +42,25 @@ documentation = "https://tvdb-api-client.readthedocs.io/en/stable/"

[tool.phosphorus.dev-dependencies]
dev = [
"ipdb~=0.13; python_version>='3.10'",
"ipython~=8.21; python_version>='3.10'",
"ipdb~=0.13",
"ipython~=8.18",
]
lint = [
"black~=24.1",
"mypy~=1.8",
"ruff~=0.5",
"black~=24.10",
"mypy~=1.12",
"ruff~=0.7",
"types-requests~=2.0",
]
test = [
"pytest~=8.0",
"pytest~=8.3",
"pytest-cov~=5.0",
]
docs = [
"mkdocs~=1.6",
"mkdocs-material~=9.5",
"mkdocs-material-extensions~=1.3",
"Pygments~=2.17",
"pymdown-extensions~=10.8",
"pygments~=2.18",
"pymdown-extensions~=10.11",
]

[tool.black]
Expand Down Expand Up @@ -122,11 +124,10 @@ select = [
"PGH",
"PERF",
"PIE",
"PLC",
"PLE",
"PLW",
"PL",
"PT",
"PTH",
"PYI",
"Q",
"RET",
"RSE",
Expand All @@ -151,6 +152,7 @@ ignore = [
"COM812",
"E501",
"FIX002",
"PLR09",
"TD002",
"TD003",
"TRY003",
Expand All @@ -159,6 +161,7 @@ ignore = [
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"FBT001",
"PLR2004",
"PT011",
"S101",
]
Expand All @@ -178,16 +181,20 @@ forced-separate = [
split-on-trailing-comma = false

[tool.pytest.ini_options]
addopts = "-vv"
addopts = "-ra -v --cov"
testpaths = "tests"

[tool.coverage.run]
branch = true
source = [
"src/",
]
data_file = ".cov_cache/coverage.dat"

[tool.coverage.report]
exclude_also = [
"if TYPE_CHECKING:",
]
show_missing = true
skip_covered = true
skip_empty = true
11 changes: 6 additions & 5 deletions src/tvdb_api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
from base64 import urlsafe_b64decode
from http import HTTPStatus
from typing import Any, Protocol, cast

import requests
Expand Down Expand Up @@ -55,11 +56,11 @@ def _generate_token(self) -> str:
data=json.dumps(self._auth_data),
timeout=(60, 120),
)
if response.status_code == 401:
if response.status_code == HTTPStatus.UNAUTHORIZED:
msg = "Invalid credentials."
raise ConnectionRefusedError(msg)

if response.status_code != 200:
if response.status_code != HTTPStatus.OK:
msg = "Unexpected Response."
raise ConnectionError(msg)

Expand All @@ -75,14 +76,14 @@ def _get(self, url: URL) -> dict[str, Any]:
headers = {"accept": "application/json", "Authorization": f"Bearer {token}"}
response = requests.get(url.string, headers=headers, timeout=(60, 120))

if response.status_code == 200:
if response.status_code == HTTPStatus.OK:
return cast(dict[str, Any], response.json())

if response.status_code in {400, 404}:
if response.status_code in {HTTPStatus.BAD_REQUEST, HTTPStatus.NOT_FOUND}:
msg = "There are no data for this term."
raise LookupError(msg)

if response.status_code == 401:
if response.status_code == HTTPStatus.UNAUTHORIZED:
msg = "Invalid credentials."
raise ConnectionRefusedError(msg)

Expand Down

0 comments on commit 4349cab

Please sign in to comment.