This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author douglas-raillard-arm
Recipients douglas-raillard-arm, rhettinger
Date 2021-02-03.10:16:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I did hit the issue while porting a tool to Python 3.9:

It basically infers valid Python expressions from type annotations (some sort
of inverse type checker) and run them while serializing all intermediate
subexpressions for debugging. This allows a whole test suite to be plain
classes and functions (usable out of context) to be assembled into "pipelines"
without extra user work. The reason I ran into that problem are:

1. I'm scanning whole modules for annotations, so it is exposed to lots of things
2. In order to be able to infer expressions, it has to augment existing
  annotations when it is unambiguous. In our case, since __new__ is more or
  less a classmethod (i.e. it takes the class as first argument even if
  strictly speaking it's a staticmethod), it added an annotation with the class
  name (extracted from __qualname__).

It implements PEP563 to evaluate the annotions, which describes how to get the
globals for a function and class and that they can be fed to eval(). Using
typing.get_type_hints() is not really possible since annotations need to be
augmented, and fancy type hints like Optional are unusable for my purpose since
there typing.get_args() was only added to Python 3.8 (I need to support >=

Maybe an alternative would be to use a module-level types.MappingProxyType
instance ? This way there is no extra object created for each namedtuple and
since it's read-only it should be as safe as None.
Date User Action Args
2021-02-03 10:16:59douglas-raillard-armsetrecipients: + douglas-raillard-arm, rhettinger
2021-02-03 10:16:59douglas-raillard-armsetmessageid: <>
2021-02-03 10:16:59douglas-raillard-armlinkissue43102 messages
2021-02-03 10:16:58douglas-raillard-armcreate