Skip to content

Commit 557d011

Browse files
committed
Actually fix recursion error with autodoc-pydantic
1 parent 8e0ab31 commit 557d011

6 files changed

Lines changed: 13 additions & 10 deletions

File tree

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"sphinx.ext.autosectionlabel",
4949
]
5050

51-
autodoc_pydantic_model_show_json_error_strategy = 'coerce'
51+
autodoc_pydantic_model_show_json = False
5252

5353
resource_links = {
5454
"repo": "https://github.com/GrandMoff100/HomeassistantAPI/",

homeassistant_api/models/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ class BaseModel(PydanticBaseModel):
2424
arbitrary_types_allowed=True,
2525
validate_assignment=True,
2626
extra="forbid",
27+
protected_namespaces=(),
2728
)

homeassistant_api/models/states.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
from pydantic import Field
77

8-
from homeassistant_api.utils import JSONType
9-
108
from homeassistant_api.models.base import BaseModel, DatetimeIsoField
9+
from homeassistant_api.utils import JSONType
1110

1211
__all__ = (
1312
"Context",

homeassistant_api/processing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
from requests import Response
1212
from requests_cache.models.response import CachedResponse
1313

14-
from homeassistant_api.utils import JSONType
15-
1614
from homeassistant_api.errors import (
1715
EndpointNotFoundError,
1816
InternalServerError,
@@ -23,6 +21,7 @@
2321
UnauthorizedError,
2422
UnexpectedStatusCodeError,
2523
)
24+
from homeassistant_api.utils import JSONType
2625

2726
logger = logging.getLogger(__name__)
2827

homeassistant_api/rawclient.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
import requests
2323
import requests_cache
2424

25-
from homeassistant_api.utils import JSONType, prepare_entity_id
26-
2725
from homeassistant_api.errors import BadTemplateError, RequestError, RequestTimeoutError
2826
from homeassistant_api.models import (
2927
Domain,
@@ -36,6 +34,7 @@
3634
)
3735
from homeassistant_api.processing import Processing, ResponseType
3836
from homeassistant_api.rawbaseclient import RawBaseClient
37+
from homeassistant_api.utils import JSONType, prepare_entity_id
3938

4039
if TYPE_CHECKING:
4140
from homeassistant_api import Client

homeassistant_api/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import re
2-
from typing import Optional, Union
3-
from typing_extensions import TypeAlias
2+
from typing import TYPE_CHECKING, Optional, Union
43

4+
from typing_extensions import TypeAlias
55

6-
JSONType: TypeAlias = Union[int, float, str, bool, list["JSONType"], dict[str, "JSONType"]]
6+
if TYPE_CHECKING:
7+
JSONType: TypeAlias = Union[
8+
int, float, str, bool, list["JSONType"], dict[str, "JSONType"]
9+
]
10+
else:
11+
JSONType = type("JSONType", (object,), {})
712

813

914
def format_entity_id(entity_id: str) -> str:

0 commit comments

Comments
 (0)