[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Larry Hastings
Larry Hastings added the comment: And I just had a realization. Lazy creation of an empty annotations dict, for both classes and modules, will work fine. As stated in my previous comment in this issue, my goal here is to improve best practices in 3.10+, while preserving the unfortunate

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Larry Hastings
Larry Hastings added the comment: I'm please you folks are as supportive as you are of what I'm doing here, given that you seem a little unsure of the details. I concede that there's a lot going on and it can be hard to keep it all in your head. The point of this issue / PR is to improve th

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Eric V. Smith
Eric V. Smith added the comment: "It's fine to have advice ..." -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Eric V. Smith
Eric V. Smith added the comment: It's find to have advice of "do X in 3.9", and "do Y in 3.10+". I think the issue is: if you have code that needs to run in 3.9 and 3.10+, what should you do? There needs to be some advice for that case. -- ___ Pyt

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Larry Hastings
Larry Hastings added the comment: I'm not breaking backwards compatibility--that's the point of all this. But I'm improving the experience. And if you don't care about 3.9 and before, you can stick to the new improved experience. Looking in the class dict for annotations is terrible, but t

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Guido van Rossum
Guido van Rossum added the comment: And that’s a problem. There needs to be a recommendation on what to do for code that spans 3.9 and 3.10. What should users do otherwise? Drop 3.9 as soon as they introduce 3.10 support? Withhold 3.10 support until 3.9 reaches EOL? IOW you can’t just break b

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-24 Thread Larry Hastings
Larry Hastings added the comment: > I’d say that best practices for 3.9+ are more useful. My point in writing this up was that the best practices change as of 3.10. So, I could add a section to the Python 3.10 documentation giving best practices for 3.10+ and 3.9-. But 3.9 and 3.10 have dif

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Guido van Rossum
Guido van Rossum added the comment: I’d say that best practices for 3.9+ are more useful. There seem to be several contradictions in your remarks, but we’ll get to those in the review. -- nosy: +Guido.van.Rossum ___ Python tracker

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings
Larry Hastings added the comment: > * Never modify o.__annotations__. Let me revise that to: * If o.__annotations__ is a dict, never modify the contents of that dict. -- ___ Python tracker

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings
Larry Hastings added the comment: It occurs to me that part of this work should also be a new "best practices for __annotations__" entry in the Python docs. Best practices for working with annotations, for code that requires a minimum Python version of 3.10+: Best practice is to call eithe

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings
Larry Hastings added the comment: By the way, here's a tidbit I never got around to posting in c.l.p-d. I noted in the conversation in January that attrs is an outlier here: it *doesn't* look in the class dict for __annotations__. Instead, it has some complicated code where it asks the clas

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings
Larry Hastings added the comment: > - Is it possible to create __annotations__ lazily? (IIRC in January we came > to a conclusion about this, something like yes for modules but for classes, > or the other way around?) Maybe for modules, definitely not for classes. The problem is that best

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Guido van Rossum
Guido van Rossum added the comment: Sounds like a plan, I agree that the original design misfired here (we were probably worried about million-line code bases with tens of thousands of classes having to pay the price of tens of thousands of empty dicts, but I now think that was an unnecessar

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Guido van Rossum
Change by Guido van Rossum : -- nosy: +gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Eric V. Smith
Change by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-21 Thread Larry Hastings
Larry Hastings added the comment: Preliminary patch is 17 lines. Ah well. I must be terrible at this! -- ___ Python tracker ___ _

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-20 Thread Larry Hastings
Larry Hastings added the comment: Huh. The sample code in my thread got goofed up somewhere along the way--maybe it's my fault, maybe it was done to me by some automated process. Anyway, the example demonstrating classes inheriting annotations was meant to be formatted like this: clas

[issue43901] Add an empty annotations dict to all unannotated classes and modules

2021-04-20 Thread Larry Hastings
Change by Larry Hastings : -- title: Add an empty annotations dict to all classes and modules -> Add an empty annotations dict to all unannotated classes and modules ___ Python tracker __