Growing pains for typing in Python
Growing pains for typing in Python
Posted Jan 18, 2024 17:08 UTC (Thu) by pizza (subscriber, #46)In reply to: Growing pains for typing in Python by aigarius
Parent article: Growing pains for typing in Python
...except, of course, when it doesn't. Which is the entire point of this discussion.
BTW, the term for what you're referring to is "interfaces", and that is typically enforced by the same language mechanism that enforces typing. (It's routinely used in large/distributed Java environments in particular))
Posted Jan 19, 2024 16:41 UTC (Fri)
by aigarius (subscriber, #7329)
[Link]
A person needs to determine if there is a *logical* sense in *how* function B is using methods on class A. No type system can tell you that.
And those can be really simple things, like sorting objects in ascending order or serialization them to JSON for RPC calls.
I just hit one such case today, that is broken right now inside the Python standard library. If you use pathlib Path objects and construct a complex, multilevel dict with the Path objects somewhere in the structure and then try to pass this structure to another server via jsonrpc call, well the whole thing comes crashing down because the Path objects are not JSON-serializable. Even if they are just used as a fancier proxy for simple text strings. If you use fancy types you get punished with fancy failures.
Growing pains for typing in Python