diff --git a/telegrinder/model.py b/telegrinder/model.py index 9afc832..ff1ec93 100755 --- a/telegrinder/model.py +++ b/telegrinder/model.py @@ -79,7 +79,7 @@ class DataConverter: def __repr__(self) -> str: return "<{}: {}>".format( self.__class__.__name__, - ", ".join(f"{k}={v!r}" for k, v in self.converters), + ", ".join(f"{k}={v.__name__!r}" for k, v in self.converters.items()), ) @property diff --git a/telegrinder/types/objects.py b/telegrinder/types/objects.py index 6c2272d..11f4c70 100644 --- a/telegrinder/types/objects.py +++ b/telegrinder/types/objects.py @@ -1,6 +1,6 @@ import typing -from fntypes.co import Some, Variative +from fntypes.co import Variative from telegrinder.model import Model from telegrinder.msgspec_utils import Nothing, Option, datetime @@ -5518,7 +5518,7 @@ class RevenueWithdrawalStatePending(RevenueWithdrawalState): The withdrawal is in progress. """ - type: str + type: typing.Literal["pending"] """Type of the state, always `pending`.""" @@ -5528,7 +5528,7 @@ class RevenueWithdrawalStateSucceeded(RevenueWithdrawalState): The withdrawal succeeded. """ - type: str + type: typing.Literal["succeeded"] """Type of the state, always `succeeded`.""" date: datetime @@ -5544,7 +5544,7 @@ class RevenueWithdrawalStateFailed(RevenueWithdrawalState): The withdrawal failed and the transaction was refunded. """ - type: str + type: typing.Literal["failed"] """Type of the state, always `failed`.""" @@ -5554,7 +5554,7 @@ class TransactionPartnerFragment(TransactionPartner): Describes a withdrawal transaction with Fragment. """ - type: str + type: typing.Literal["fragment"] """Type of the transaction partner, always `fragment`.""" withdrawal_state: Option[ @@ -5571,7 +5571,7 @@ class TransactionPartnerUser(TransactionPartner): Describes a transaction with a user. """ - type: str + type: typing.Literal["user"] """Type of the transaction partner, always `user`.""" user: "User" @@ -5584,7 +5584,7 @@ class TransactionPartnerOther(TransactionPartner): Describes a transaction with an unknown source or recipient. """ - type: str + type: typing.Literal["other"] """Type of the transaction partner, always `other`.""" diff --git a/typegen/config_literal_types.json b/typegen/config_literal_types.json index 3d7c31a..4331d67 100755 --- a/typegen/config_literal_types.json +++ b/typegen/config_literal_types.json @@ -239,6 +239,72 @@ } ] }, + { + "name": "RevenueWithdrawalStatePending", + "fields": [ + { + "name": "type", + "literals": [ + "pending" + ] + } + ] + }, + { + "name": "RevenueWithdrawalStateSucceeded", + "fields": [ + { + "name": "type", + "literals": [ + "succeeded" + ] + } + ] + }, + { + "name": "RevenueWithdrawalStateFailed", + "fields": [ + { + "name": "type", + "literals": [ + "failed" + ] + } + ] + }, + { + "name": "TransactionPartnerFragment", + "fields": [ + { + "name": "type", + "literals": [ + "fragment" + ] + } + ] + }, + { + "name": "TransactionPartnerUser", + "fields": [ + { + "name": "type", + "literals": [ + "user" + ] + } + ] + }, + { + "name": "TransactionPartnerOther", + "fields": [ + { + "name": "type", + "literals": [ + "other" + ] + } + ] + }, { "name": "EncryptedPassportElement", "fields": [ diff --git a/typegen/nicifications.py b/typegen/nicifications.py index d728f6a..d785213 100755 --- a/typegen/nicifications.py +++ b/typegen/nicifications.py @@ -145,26 +145,20 @@ def full_name(self) -> str: class _Update(Update): def __eq__(self, other: typing.Any) -> bool: - return ( - isinstance(other, self.__class__) - and self.update_type.map( - lambda x: x == other.update_type.unwrap_or_none(), - ).unwrap_or(False) - ) + return isinstance(other, self.__class__) and self.update_type == other.update_type @property - def update_type(self) -> Option[UpdateType]: + def update_type(self) -> UpdateType: """Incoming update type.""" - if update := next( - filter( - lambda x: bool(x[1]), - self.to_dict(exclude_fields={"update_id"}).items(), - ), - None, - ): - return Some(UpdateType(update[0])) - return Nothing + return UpdateType( + next( + filter( + lambda x: bool(x[1]), + self.to_dict(exclude_fields={"update_id"}).items(), + ), + )[0], + ) class _InputFile(typing.NamedTuple):