Skip to content

Commit adb44c1

Browse files
committed
version 4.0.1
1 parent 1e1400e commit adb44c1

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

docs/additional_info/changelog.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Changelog
44
=========
55

6+
4.0.1 (29-Sep-2025)
7+
-------------------
8+
9+
* Fix types for errors
10+
611
4.0.0 (29-Sep-2025)
712
-------------------
813

lokalise/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
This module contains plugin metadata.
55
"""
66

7-
__version__: str = "4.0.0"
7+
__version__: str = "4.0.1"

lokalise/errors.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ def __init__(
3636
self.status_code = status_code
3737
self.message = message
3838
self.headers: dict[str, str] = dict(headers or {})
39-
self.raw_text = raw_text
40-
self.parsed = parsed
39+
self.raw_text: str | None = raw_text
40+
self.parsed: APIError | None = parsed
4141

4242
def __str__(self) -> str:
4343
base = f"{self.status_code} {self.message}"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "python-lokalise-api"
3-
version = "4.0.0"
3+
version = "4.0.1"
44
description = "Official Python interface for the Lokalise API v2"
55
authors = [
66
{name = "Ilya Krukowski", email = "elskruk@proton.me"}

tests/client/client_setup_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_reset_client_allows_reloading_endpoints(client: lokalise.Client) -> Non
184184

185185

186186
def test_get_endpoint_populates_when_attr_is_none(client: lokalise.Client) -> None:
187-
client._projects_endpoint = None
187+
client._projects_endpoint = None # type: ignore[attr-defined]
188188
ep = client.get_endpoint("projects")
189189
assert ep is not None
190190

tests/client/errors_test.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ def test_not_found(client: lokalise.Client) -> None:
1717
client.project("123/invalid/")
1818

1919
exc = excinfo.value
20+
assert isinstance(exc, lokalise.errors.ClientHTTPError)
2021
assert exc.status_code == 404
22+
assert isinstance(exc.message, str)
23+
assert isinstance(exc.headers, dict)
24+
assert isinstance(exc.raw_text, str) or exc.raw_text is None
25+
assert exc.parsed is not None
26+
assert isinstance(exc.parsed, lokalise.errors.APIError)
27+
assert exc.parsed.status == 404
28+
assert isinstance(exc.parsed.message, str)
29+
assert isinstance(exc.parsed.reason, str)
30+
assert exc.parsed.code is None or isinstance(exc.parsed.code, (int, str))
31+
assert exc.parsed.details is None or isinstance(exc.parsed.details, dict)
2132

2233

2334
@pytest.mark.vcr
@@ -49,7 +60,14 @@ def test_invalid_client():
4960
with pytest.raises(lokalise.errors.BadRequest) as excinfo:
5061
invalid_client.projects()
5162

52-
assert excinfo.value.status_code == 400
63+
exc = excinfo.value
64+
assert exc.status_code == 400
65+
assert isinstance(exc.message, str)
66+
assert isinstance(exc.headers, dict)
67+
assert isinstance(exc.raw_text, str)
68+
assert exc.parsed is not None
69+
assert exc.parsed.status == 400
70+
assert isinstance(exc.parsed.details, (dict, type(None)))
5371

5472

5573
@pytest.mark.vcr

typings/lokalise/errors.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
from typing import Any
2+
13
class ClientError(Exception): ...
24

35
class ClientHTTPError(ClientError):
46
status_code: int
57
headers: dict[str, str]
68
raw_text: str | None
79
parsed: APIError | None
10+
message: str
811

912
class BadRequest(ClientHTTPError): ...
1013
class Unauthorized(ClientHTTPError): ...
@@ -26,7 +29,7 @@ class APIError:
2629
reason: str
2730
raw: str
2831
code: int | str | None
29-
details: dict[str, object] | None
32+
details: dict[str, Any] | None
3033

3134
__all__ = [
3235
"ClientError",

0 commit comments

Comments
 (0)