Às 22:34 de 29/10/22, dn escreveu:
Out of interest, tested snippet in PyCharm, cf native-mypy. It flags the
original:
GLOBALS.foos: Optional[Foos]=Foos()
but not the fall-back:
GLOBALS.foos=Foos()
Must admit, the first query coming to mind was: why is the typing taking
place at initialisation-time, rather than within the (class) definition?
At definition time "foos" has already been typed as None by implication!
Solution (below) will not work if the mention of Foos in GLOBALS is a
forward-reference. Either move GLOBALS to suit, or surround "Foos" with
quotes.
Somehow I missed this sentence the 1st. time I read this post :-(
This is good enough to me! Thank you.
I didn't know about this "quoting" thing.
Regards
Paulo
--
https://mail.python.org/mailman/listinfo/python-list