Skip to content

Commit

Permalink
Rename EsmeraldSignature to SignatureModel
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsil committed May 21, 2024
1 parent bff586e commit 07b603b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions esmerald/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from esmerald.core.di.provider import load_provider
from esmerald.parsers import ArbitraryHashableBaseModel
from esmerald.transformers.signature import EsmeraldSignature
from esmerald.transformers.signature import SignatureModel
from esmerald.typing import Void
from esmerald.utils.helpers import is_async_callable

Expand Down Expand Up @@ -56,7 +56,7 @@ class Inject(ArbitraryHashableBaseModel):
def __init__(self, dependency: "AnyCallable", use_cache: bool = False, **kwargs: Any):
super().__init__(**kwargs)
self.dependency = dependency
self.signature_model: Optional["Type[EsmeraldSignature]"] = None
self.signature_model: Optional["Type[SignatureModel]"] = None
self.use_cache = use_cache
self.value: Any = Void

Expand Down
2 changes: 1 addition & 1 deletion esmerald/routing/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from esmerald.routing.events import handle_lifespan_events
from esmerald.routing.gateways import Gateway, WebhookGateway, WebSocketGateway
from esmerald.transformers.model import TransformerModel
from esmerald.transformers.signature import EsmeraldSignature as SignatureModel
from esmerald.transformers.signature import SignatureModel
from esmerald.transformers.utils import get_signature
from esmerald.typing import Void, VoidType
from esmerald.utils.constants import DATA, PAYLOAD, REDIRECT_STATUS_CODES, REQUEST, SOCKET
Expand Down
2 changes: 1 addition & 1 deletion esmerald/transformers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from esmerald.exceptions import ImproperlyConfigured
from esmerald.parsers import ArbitraryExtraBaseModel, parse_form_data
from esmerald.requests import Request
from esmerald.transformers.signature import EsmeraldSignature as SignatureModel
from esmerald.transformers.signature import SignatureModel
from esmerald.transformers.utils import (
Dependency,
ParamSetting,
Expand Down
10 changes: 5 additions & 5 deletions esmerald/transformers/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def default_defined(self) -> bool:
return self.default not in UNDEFINED


class EsmeraldSignature(ArbitraryBaseModel):
class SignatureModel(ArbitraryBaseModel):
dependency_names: ClassVar[Set[str]]
return_annotation: ClassVar[Any]
encoders: ClassVar[Dict[str, Any]]
Expand Down Expand Up @@ -253,9 +253,9 @@ def handle_encoders(
continue
return custom_encoders

def create_signature(self) -> Type[EsmeraldSignature]:
def create_signature(self) -> Type[SignatureModel]:
"""
Creates the EsmeraldSignature based on the type of parameters.
Creates the SignatureModel based on the type of parameters.
This allows to understand if the msgspec is also available and allowed.
"""
Expand All @@ -272,9 +272,9 @@ def create_signature(self) -> Type[EsmeraldSignature]:
continue
self.field_definitions[param.name] = get_field_definition_from_param(param)

model: Type["EsmeraldSignature"] = create_model(
model: Type["SignatureModel"] = create_model(
self.fn_name + "_signature",
__base__=EsmeraldSignature,
__base__=SignatureModel,
**self.field_definitions,
)
model.return_annotation = self.signature.return_annotation
Expand Down
6 changes: 3 additions & 3 deletions esmerald/transformers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

if TYPE_CHECKING: # pragma: no cover
from esmerald.injector import Inject
from esmerald.transformers.signature import EsmeraldSignature, Parameter
from esmerald.transformers.signature import Parameter, SignatureModel
from esmerald.types import ConnectionType


Expand Down Expand Up @@ -201,9 +201,9 @@ def get_connection_info(connection: "ConnectionType") -> Tuple[str, "URL"]:
return method, connection.url


def get_signature(value: Any) -> Type["EsmeraldSignature"]:
def get_signature(value: Any) -> Type["SignatureModel"]:
try:
return cast("Type[EsmeraldSignature]", value.signature_model)
return cast("Type[SignatureModel]", value.signature_model)
except AttributeError as exc:
raise ImproperlyConfigured(f"The 'signature' attribute for {value} is not set.") from exc

Expand Down

0 comments on commit 07b603b

Please sign in to comment.