
Larry Hastings wrote:
The control-flow exclusion is for /module//attribute/ or /class attribute/ annotations: class C: if random.random() > 0.5: my_attr:int=3 else: my_attr2:float=3.5
That very example would be helpful in the FAQ, though I understand if you're concerned about making a minor sub-section seem too long. If I understand correctly, the problem is that you can't store multiple alternative annotations on my_attr. Therefore: class C: my_attr:(int if random.random > 0.5 else float) should be OK, because there is only a single annotation. What about optional attributes, like: class C: if random.random() > 0.5: my_attr:int=3 Also, would (conditionally defined) function variable attributes become a problem if they were actually stored? (Take Larry's class example, and make if a def instead of a class statement.) My (weakly held, personal) opinion is that these restrictions would be reasonable, and a single release of deprecation would be enough, but it would be better if that code could trigger a deprecation warning during that release, even for code that hasn't done the future import. It would also be OK to just say "implementation-defined behavior; CPython 3.x ignores the annotation" instead of banning them. -jJ