|
|
|
|
|
by _dain_
1113 days ago
|
|
Does the type system let you express that a class shouldn't be subclassed? I remember this possibility was mentioned in a PEP and got deferred. It would be really useful with the new match/case pattern matching feature, because then you could have proper sum types, and mypy could enforce exhaustiveness. AFAIK you have to do a workaround with a "assert False" or similar at the end. |
|
But that's only checked by the type checker. At runtime you still need to do something like this to prevent subclassing: