[issue40583] Runtime type annotation mutation leads to inconsistent behavior

2020-05-15 Thread Saumitro Dasgupta
Change by Saumitro Dasgupta : -- resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue40583] Runtime type annotation mutation leads to inconsistent behavior

2020-05-15 Thread Saumitro Dasgupta
Saumitro Dasgupta added the comment: Fair enough. If that's the consensus, I'll close the issue. -- ___ Python tracker <https://bugs.python.o

[issue40583] Runtime type annotation mutation leads to inconsistent behavior

2020-05-15 Thread Saumitro Dasgupta
Saumitro Dasgupta added the comment: I'd argue that the situation is a bit different from class variables here, since __annotations__ is indirectly brought into existence by the presence of statically-established type annotations. You can be perfectly aware of how class variables wor

[issue40583] Runtime type annotation mutation leads to inconsistent behavior

2020-05-15 Thread Saumitro Dasgupta
Saumitro Dasgupta added the comment: In my opinion, the main problem here is the element of surprise. Given a statement like this: foo.__annotations__['injected'] = bool the expressed intent is "extend this object's annotations". It's surprising t

[issue40583] Runtime type annotation mutation leads to inconsistent behavior

2020-05-10 Thread Saumitro Dasgupta
New submission from Saumitro Dasgupta : Adding type annotations at runtime may lead to inconsistent results. Consider the following example: class Base: base: int class Alpha(Base): pass class Beta(Base): foobar: int # Case 1: This mutates Base&#