Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
spapanik committed Feb 5, 2024
1 parent 47f22e7 commit bf10120
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root=true
root = true

[*]
end_of_line = lf
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- name: Checkout the repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -51,6 +52,7 @@ jobs:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
steps:
- name: Checkout the repository
uses: actions/checkout@v3
Expand Down
80 changes: 0 additions & 80 deletions cookbook.toml

This file was deleted.

45 changes: 45 additions & 0 deletions cookbook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
$globals:
shell: bash
version: "6.0"
vars:
poetry_sync: "--sync"

install:
phony: true
keep_ts: true
requires:
- poetry.lock
commands:
- "poetry install ${poetry_sync} ${poetry_extra}"

format:
phony: true
requires:
- install
commands:
- black .
- ruff --fix-only .

lint:
phony: true
requires:
- install
commands:
- black --check .
- poetry check --lock
- ruff .
- mypy .

tests:
phony: true
requires:
- install
commands:
- "pytest ${pytest_args} ${pytest_path} ${.extra}"

poetry.lock:
update: true
requires:
- pyproject.toml
commands:
- poetry lock
75 changes: 52 additions & 23 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[build-system]
requires = ["poetry_core>=1.0.0"]
requires = [
"poetry_core>=1.0.0",
]
build-backend = "poetry.core.masonry.api"

[tool.black]
target-version = ["py38"]
target-version = [
"py38",
]

[tool.mypy]
check_untyped_defs = true
Expand All @@ -13,10 +17,10 @@ disallow_subclassing_any = true
disallow_untyped_calls = true
disallow_untyped_decorators = true
disallow_untyped_defs = true
extra_checks = true
ignore_missing_imports = true
no_implicit_reexport = true
show_error_codes = true
strict_concatenate = true
strict_equality = true
warn_return_any = true
warn_redundant_casts = true
Expand All @@ -25,74 +29,94 @@ warn_unreachable = true
warn_unused_configs = true

[tool.ruff]
src = [
"src",
]
target-version = "py38"

[tool.ruff.lint]
select = [
"A",
"ARG",
"ASYNC",
"B",
"BLE",
"C4",
"COM",
"DTZ",
"E",
"EM",
"ERA",
"EXE",
"F",
"FA",
"FBT",
"FLY",
"G",
"I",
"ICN",
"INP",
"ISC",
"LOG",
"N",
"PGH",
"PERF",
"PIE",
"PLC",
"PLE",
"PLW",
"PT",
"PTH",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"SLF",
"SLOT",
"T10",
"TID",
"TRY",
"UP",
"W",
"YTT",
]
ignore = [
"COM812",
"E501",
"TRY003",
]
src = ["src"]
target-version = "py38"

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"FBT001",
"PT011",
"S101",
]

[tool.ruff.flake8-tidy-imports]
[tool.ruff.lint.flake8-tidy-imports]
ban-relative-imports = "all"

[tool.ruff.flake8-tidy-imports.banned-api]
[tool.ruff.lint.flake8-tidy-imports.banned-api]
"mock".msg = "Use unittest.mock"
"pytz".msg = "Use zoneinfo"

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true
forced-separate = ["tests"]
forced-separate = [
"tests",
]
split-on-trailing-comma = false

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

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

[tool.coverage.report]
Expand All @@ -115,7 +139,11 @@ homepage = "https://tvdb-api-client.readthedocs.io/en/stable/"
repository = "https://github.com/spapanik/tvdb_api_client"
documentation = "https://tvdb-api-client.readthedocs.io/en/stable/"

keywords = ["tvdb", "imdb", "tv series"]
keywords = [
"tvdb",
"imdb",
"tv series",
]
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: OS Independent",
Expand All @@ -131,20 +159,21 @@ pathurl = "^0.6"
requests = "^2.0"

[tool.poetry.group.dev.dependencies]
ipdb = {version = "^0.13", python = "^3.9"}
ipython = {version = "^8.12", python = "^3.9"}
pipdeptree = "^2.7"
ipdb = { version = "^0.13", python = "^3.10" }
ipython = { version = "^8.21", python = "^3.10" }
pickleshare = { version = "^0.7", python = "^3.10" }
pipdeptree = "^2.13"

[tool.poetry.group.lint.dependencies]
black = "^23.3"
mypy = "^1.4"
ruff = "^0.0"
types-requests = "^2.28"
black = "^24.1"
mypy = "^1.8"
ruff = "^0.2"
types-requests = "^2.0"

[tool.poetry.group.test.dependencies]
pytest = "^7.4"
pytest-cov = "^4.0"
pytest = "^8.0"
pytest-cov = "^4.1"

[tool.poetry.group.docs.dependencies]
furo = "^2023.5"
sphinx = "^7.0"
furo = { version = "^2024.1", python = "^3.10" }
sphinx = { version = "^7.2", python = "^3.10" }
23 changes: 13 additions & 10 deletions src/tvdb_api_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@


class AbstractCache(Protocol):
def set(self, key: str, value: Any) -> None: # noqa: A003
...
def set(self, key: str, value: Any) -> None: ...

def get(self, key: str) -> Any:
...
def get(self, key: str) -> Any: ...


class _Cache(dict): # type: ignore[type-arg]
def set(self, key: str, value: Any) -> None: # noqa: A003
def set(self, key: str, value: Any) -> None:
self[key] = value


Expand Down Expand Up @@ -58,10 +56,12 @@ def _generate_token(self) -> str:
timeout=(60, 120),
)
if response.status_code == 401:
raise ConnectionRefusedError("Invalid credentials.")
msg = "Invalid credentials."
raise ConnectionRefusedError(msg)

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

return cast(str, response.json()["data"]["token"])

Expand All @@ -79,12 +79,15 @@ def _get(self, url: URL) -> dict[str, Any]:
return cast(dict[str, Any], response.json())

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

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

raise ConnectionError("Unexpected Response.")
msg = "Unexpected Response."
raise ConnectionError(msg)

def get_raw_series_by_id(
self, tvdb_id: int, *, refresh_cache: bool = False
Expand Down
Loading

0 comments on commit bf10120

Please sign in to comment.