3 ms·
> Yeah this is great, __init_subclass__ comes along to make dynamic injection of methods and attributes on class creation easier, just as the entire practice is
by dragonwriter 5y ago
> Yeah this is great, __init_subclass__ comes along to make dynamic injection of methods and attributes on class creation easier, just as the entire practice is fast becoming fully obsolete because type checkers like pylance and mypy report these attributes and methods as errors.
The Python community and the set of people that treat mypy and pylance as dictators rather than tools to be used where appropriate and turned off where not are...not the same thing. (And the latter very much depends on tools built by the rest of the former that internally are wild and woolly, even if they present a nice cleanly typed interface to the consumer.)
- zzzeek 5y agosure...im coming from the library producer perspective. it's not very easy for us to say, "just turn off the type checker when you use our library" :)
- Too 5y agoMypy is scoped to have different levels of checking per package. Normally it doesn’t scan third party libraries beyond the signature of public functions. See the follow_imports options.
- dragonwriter 5y ago> it's not very easy for us to say, "just turn off the type checker when you use our library" :) Sure, and that is a problem with exposing certain kinds of dynamism when your customer base is the kind that is inflexible about typing. OTOH, a lot can still be done with dynamism on the inside and a typed public interface, and also there's a significant part of the community that accepts selective disabling of typechecking as an acceptable when dynamism provides adequate benefits.