Skip to content

Commit

Permalink
OPT: remove RootModel where it is unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Nov 4, 2023
1 parent 8df4f55 commit 9cf3992
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 2 additions & 2 deletions combadge/support/zeep/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# Before Python 3.10:
UnionType = type(Union[int, str]) # type: ignore[assignment, misc]

from pydantic import RootModel, TypeAdapter
from pydantic import TypeAdapter
from typing_extensions import get_args as get_type_args
from typing_extensions import get_origin as get_type_origin
from zeep.exceptions import Fault
Expand All @@ -29,7 +29,7 @@

_OperationProxyT = TypeVar("_OperationProxyT", bound=OperationProxy)

_SoapFaultT = TypeVar("_SoapFaultT", bound=RootModel[Any])
_SoapFaultT = TypeVar("_SoapFaultT")
"""Specific SOAP Fault model type."""

_UNSET = object()
Expand Down
12 changes: 3 additions & 9 deletions tests/integration/test_country_info_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
from pathlib import Path
from typing import Iterable, List, Protocol

from pydantic import BaseModel, Field, RootModel
from pydantic import BaseModel, Field
from pytest import fixture, mark
from typing_extensions import Annotated
from zeep import Client

from combadge.core.interfaces import SupportsService
from combadge.core.response import SuccessfulResponse
from combadge.support.http.markers import Payload
from combadge.support.soap.markers import operation_name
from combadge.support.zeep.backends.sync import ZeepBackend
Expand All @@ -23,14 +22,10 @@ class Continent(BaseModel):
name: Annotated[str, Field(alias="sName")]


class CountryInfoResponse(RootModel, SuccessfulResponse):
root: List[Continent]


class SupportsCountryInfo(SupportsService, Protocol):
@operation_name("ListOfContinentsByName")
@abstractmethod
def list_of_continents_by_name(self, request: Payload[CountryInfoRequest]) -> CountryInfoResponse:
def list_of_continents_by_name(self, request: Payload[CountryInfoRequest]) -> List[Continent]:
raise NotImplementedError


Expand All @@ -42,9 +37,8 @@ def country_info_service() -> Iterable[SupportsCountryInfo]:

@mark.vcr(decode_compressed_response=True)
def test_happy_path(country_info_service: SupportsCountryInfo) -> None:
response = country_info_service.list_of_continents_by_name(CountryInfoRequest())
continents = country_info_service.list_of_continents_by_name(CountryInfoRequest())

continents = response.root
assert isinstance(continents, list)
assert len(continents) == 6
assert continents[0].code == "AF"
Expand Down

0 comments on commit 9cf3992

Please sign in to comment.