3 ms·
In python nothing can guarantee at compile time that you are not passing a username variable in a method that accepts an email address. You'll just notice at ru
by tigershark 10y ago
In python nothing can guarantee at compile time that you are not passing a username variable in a method that accepts an email address.
You'll just notice at runtime when you realise that you have to rollback your last deployment because new users are unable to receive the activation email that is being sent to their username instead of their email.
- cabalamat 10y ago> In python nothing can guarantee at compile time that you are not passing a username variable in a method that accepts an email address Is there no reason you could not create an Email class and have the method require its argument to be of that type?
- minitech 10y ago> guarantee at compile time If you’re talking about runtime type checks rather than mypy, well, they’re just verbose static types with less safety. (May as well just embrace the duck typing at that point by accessing email.local_part and letting the AttributeError propagate.)