From 21378d049a1dd865f0b84441ef443ad6251b0947 Mon Sep 17 00:00:00 2001 From: Tobi DEGNON Date: Thu, 10 Aug 2023 10:09:41 +0100 Subject: [PATCH] refactor: simpler type specification for Numeric --- dj_shop_cart/protocols.py | 48 ++++----------------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/dj_shop_cart/protocols.py b/dj_shop_cart/protocols.py index 1df8b30..f986ec5 100644 --- a/dj_shop_cart/protocols.py +++ b/dj_shop_cart/protocols.py @@ -1,12 +1,15 @@ from __future__ import annotations +from decimal import Decimal +from django.http import HttpRequest + try: - from typing import Protocol + from typing import Protocol, Union except ImportError: from typing_extensions import Protocol -from django.http import HttpRequest +Numeric = Union[float, int, Decimal] class Storage(Protocol): @@ -20,44 +23,3 @@ def save(self, data: dict) -> None: def clear(self) -> None: ... - - -class Numeric(Protocol): - def __add__(self, *args, **kwargs) -> Numeric: - ... - - def __sub__(self, *args, **kwargs) -> Numeric: - ... - - def __mul__(self, *args, **kwargs) -> Numeric: - ... - - def __truediv__(self, *args, **kwargs) -> Numeric: - ... - - def __floordiv__(self, *args, **kwargs) -> Numeric: - ... - - def __mod__(self, *args, **kwargs) -> Numeric: - ... - - def __pow__(self, *args, **kwargs) -> Numeric: - ... - - def __lt__(self, *args, **kwargs) -> bool: - ... - - def __le__(self, *args, **kwargs) -> bool: - ... - - def __eq__(self, *args, **kwargs) -> bool: - ... - - def __ne__(self, *args, **kwargs) -> bool: - ... - - def __gt__(self, *args, **kwargs) -> bool: - ... - - def __ge__(self, *args, **kwargs) -> bool: - ...