Skip to content

Commit

Permalink
fix mypy issues with __call_ order on multiple inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
loechel committed Apr 23, 2024
1 parent 9b76185 commit f4d137b
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 49 deletions.
6 changes: 3 additions & 3 deletions src/edutap/wallet_google/api.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .modelbase import GoogleWalletModel
from .modelbase import GoogleWalletObjectWithClassReference
from .modelcore import GoogleWalletModel
from .models.primitives import Pagination
from .models.primitives.enums import State
from .models.primitives.notification import AddMessageRequest
from .models.primitives.notification import Message
from .models.primitives.message import AddMessageRequest
from .models.primitives.message import Message
from .registry import lookup_metadata
from .registry import lookup_model
from .registry import lookup_model_by_plural_name
Expand Down
10 changes: 5 additions & 5 deletions src/edutap/wallet_google/modelbase.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .modelcore import GoogleWalletModel
from .modelcore import GoogleWalletWithIdModel
from .models.primitives import CallbackOptions
from .models.primitives import GroupingInfo
Expand All @@ -14,7 +13,8 @@
from .models.primitives.data import TextModuleData
from .models.primitives.enums import MultipleDevicesAndHoldersAllowedStatus
from .models.primitives.enums import ViewUnlockRequirement
from .models.primitives.notification import Message
from .models.primitives.message import Message
from pydantic import BaseModel
from pydantic import Field


Expand Down Expand Up @@ -120,23 +120,23 @@ class GoogleWalletObjectModel(GoogleWalletWithIdModel):
rotatingBarcode: RotatingBarcode | None = None


class GoogleWalletObjectWithClassReference(GoogleWalletObjectModel):
class GoogleWalletObjectWithClassReference(BaseModel):
"""
Model for all Google Wallet Object with a Class references.
"""

classReference: GoogleWalletClassModel | None = None


class GoogleWalletMessageable(GoogleWalletModel):
class GoogleWalletMessageable:
"""
Model for Google Wallet Classes or Objects that can retrieve Messages
"""

messages: list[Message] | None = None


class GoogleWalletStyleable(GoogleWalletModel):
class GoogleWalletStyleable:
"""
Model for Google Wallet Classes or Objects that can be styled
"""
Expand Down
12 changes: 10 additions & 2 deletions src/edutap/wallet_google/modelcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ class GoogleWalletModel(BaseModel):
)


class GoogleWalletWithIdModel(GoogleWalletModel):
class GoogleWalletWithKindModel(GoogleWalletModel):
"""
Base model for Google Wallet models with an identifier.
Base model for Google Wallet models with an deprecated kind identifier.
"""

kind: str | None = Field(description="deprecated", exclude=True, default=None)


class GoogleWalletWithIdModel(GoogleWalletWithKindModel):
"""
Base model for Google Wallet models with an identifier.
"""

# kind: str | None = Field(description="deprecated", exclude=True, default=None)
id: str
4 changes: 2 additions & 2 deletions src/edutap/wallet_google/models/issuer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from ..modelbase import GoogleWalletModel
from ..modelbase import GoogleWalletWithIdModel
from ..modelcore import GoogleWalletModel
from ..modelcore import GoogleWalletWithIdModel
from ..registry import register_model
from .primitives.smarttap import IssuerContactInfo
from .primitives.smarttap import IssuerToUserInfo
Expand Down
2 changes: 1 addition & 1 deletion src/edutap/wallet_google/models/jwt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ..modelbase import GoogleWalletClassModel
from ..modelbase import GoogleWalletModel
from ..modelbase import GoogleWalletObjectModel
from ..modelcore import GoogleWalletModel
from ..registry import register_model

# from . import generic
Expand Down
20 changes: 3 additions & 17 deletions src/edutap/wallet_google/models/primitives/datetime.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,17 @@
from .enums import DoorsOpenLabel
from .localized_string import LocalizedString
from pydantic import BaseModel
from ...modelcore import GoogleWalletModel

import datetime


class DateTime(BaseModel):
class DateTime(GoogleWalletModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/DateTime
"""

date: datetime.datetime


class EventDateTime(BaseModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass#eventdatetime
"""

doorsOpen: datetime.datetime | None = None
start: datetime.datetime | None = None
end: datetime.datetime | None = None
doorsOpenLabel: DoorsOpenLabel | None = None
customDoorsOpenLabel: LocalizedString | None = None


class TimeInterval(BaseModel):
class TimeInterval(GoogleWalletModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/TimeInterval
"""
Expand Down
19 changes: 7 additions & 12 deletions src/edutap/wallet_google/models/primitives/location.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
from .localized_string import LocalizedString
from pydantic import BaseModel
from ...modelcore import GoogleWalletWithKindModel
from pydantic import Field


class LatLongPoint(BaseModel):
class LatLongPoint(GoogleWalletWithKindModel):
"""
see: https://developers.google.com/wallet/retail/loyalty-cards/rest/v1/LatLongPoint
"""

kind: str | None = Field(
description="deprecated",
exclude=True,
default="walletobjects#latLongPoint",
)
latitude: float = Field(ge=-90.0, le=90.0)
longitude: float = Field(ge=-180.0, le=180.0)


class EventVenue(BaseModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass#eventvenue
"""

name: LocalizedString | None = None
address: LocalizedString | None = None
11 changes: 9 additions & 2 deletions src/edutap/wallet_google/models/primitives/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
from .datetime import TimeInterval
from .enums import MessageType
from .localized_string import LocalizedString
from pydantic import Field


class Message(GoogleWalletModel, GoogleWalletWithIdModel):
class Message(
GoogleWalletWithIdModel,
):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/Message
"""

# id: str | None = None
kind: str | None = Field(
description="deprecated",
exclude=True,
default="walletobjects#walletObjectMessage",
)
messageType: MessageType = MessageType.MESSAGE_TYPE_UNSPECIFIED
displayInterval: TimeInterval | None = None
header: str | None = None
Expand Down
52 changes: 48 additions & 4 deletions src/edutap/wallet_google/models/tickets_and_transit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,59 @@
from ..modelbase import GoogleWalletObjectModel
from ..modelbase import GoogleWalletObjectWithClassReference
from ..modelbase import GoogleWalletStyleable
from ..modelcore import GoogleWalletWithKindModel
from ..registry import register_model
from .primitives import Uri
from .primitives.data import AppLinkData
from .primitives.datetime import EventDateTime
from .primitives.datetime import TimeInterval
from .primitives.enums import ConfirmationCodeLabel
from .primitives.enums import DoorsOpenLabel
from .primitives.enums import GateLabel
from .primitives.enums import ReviewStatus
from .primitives.enums import RowLabel
from .primitives.enums import SeatLabel
from .primitives.enums import SectionLabel
from .primitives.enums import State
from .primitives.localized_string import LocalizedString
from .primitives.location import EventVenue
from .primitives.location import LatLongPoint
from .primitives.money import Money
from .primitives.review import Review
from pydantic import BaseModel
from pydantic import Field

import datetime


class EventVenue(GoogleWalletWithKindModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass#eventvenue
"""

kind: str | None = Field(
description="deprecated",
exclude=True,
default="walletobjects#eventDateTime",
)
name: LocalizedString | None = None
address: LocalizedString | None = None


class EventDateTime(GoogleWalletWithKindModel):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass#eventdatetime
"""

kind: str | None = Field(
description="deprecated",
exclude=True,
default="walletobjects#eventDateTime",
)
doorsOpen: datetime.datetime | None = None
start: datetime.datetime | None = None
end: datetime.datetime | None = None
doorsOpenLabel: DoorsOpenLabel | None = None
customDoorsOpenLabel: LocalizedString | None = None


@register_model(
"EventTicketClass",
Expand All @@ -31,8 +64,17 @@
can_disable=False,
)
class EventTicketClass(GoogleWalletClassModel, GoogleWalletMessageable):
"""
see: https://developers.google.com/wallet/tickets/events/rest/v1/eventticketclass
"""

kind: str | None = Field(
description="deprecated",
exclude=True,
default="walletobjects#eventTicketClass",
)
eventName: LocalizedString | None = None
eventId: str | None = None
eventId: str | None = Field(default=None, max_length=64)
venue: EventVenue | None = None
dateTime: EventDateTime | None = None
confirmationCodeLabel: ConfirmationCodeLabel | None = None
Expand Down Expand Up @@ -68,7 +110,9 @@ class EventReservationInfo(BaseModel):


@register_model(
"EventTicketObject", url_part="eventTicketObject", plural="eventTicketObjects"
"EventTicketObject",
url_part="eventTicketObject",
plural="eventTicketObjects",
)
class EventTicketObject(
GoogleWalletObjectModel,
Expand Down
2 changes: 1 addition & 1 deletion src/edutap/wallet_google/registry.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .modelbase import GoogleWalletModel
from .modelcore import GoogleWalletModel
from typing import TypedDict


Expand Down

0 comments on commit f4d137b

Please sign in to comment.