
On Sat, Nov 20, 2021 at 11:46:56PM -0800, Christopher Barker wrote:
One example is a use case of mine -- I have built a hierarchical object system, built on dataclasses, in which the annotation absolutely has to be an actual type(class) object. PEP 563 will very much break this use case.
I don't think that's an insurmountable problem. I think that all you need is a small class decorator to evaluate the stringified annotations back to the real things. The PEP tells us the right way to evaluate annotations, so all(?) you need is a decorator to do that to each method in your class, and Bob's your uncle. Maybe PEP 563 could include a decorator in the typing module to destringify all the annotations in a class or function? As far as I can see from a brief scan of the PEP, and based on knowing next to nothing about your use-case, the only hypothetical problem might be this line in the PEP: "Consequently, using local state in annotations is no longer possible in general." but it's not entirely clear to me what Łukasz means by that, or whether it will affect your use-case. -- Steve