I'm not sure if I should post this since I love both Python and enforcing constraints, but...
@final
@dataclass(frozen=True, slots=True)
class CalculatePrice(object):
_callback: Callable[[Decimal], Decimal]
On the one hand, documenting and enforcing restrictions to make code more maintainable is great.
On the other hand, what do you really gain from using Python if you're going to do things like this? The above signature in Kotlin is
class CalculatePrice(val callback: (List<Decimal>) -> Decimal)
and all that is enforced at compile time, instead of runtime (plus the argument is also immutable, and it's likely faster).
I do like Python. But I think that if you're going to make it this structured, your project has outgrown it.