Given a class object (C), is it possible to *reliably* determine whether
the class was compiled with PEP 563 (from __future__ import annotations)
enabled?

Note that simply looking for the presence of C.__module__.annotations is
not really reliable.  It will fail in the presence of any of these
constructs.

  from __future__ import annotations as ann

or

  from __future__ import annotations
  del annotations

or

 annotations = some_entirely_unrelated_thing

Testing for the presents of C.__module__.annotations will give a false
negative in the first two cases and a false positive in the last case.

--
========================================================================
If your user interface is intuitive in retrospect ... it isn't intuitive
========================================================================

--
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to