type hinting backward compatibility with python 3.0 to 3.4

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun May 21 18:46:46 EDT 2017


bartc wrote:
> In fact the declaration of A might be in a different module from its use 
> in a type hint, which means that, in the CPython byte-code compiler 
> anyway, it is not visible at compile-time, when type hints could best be 
> put to good effect.

The static type checker would have to understand enough about
imports to deal with that.

> Furthermore, both A, and the type-hinting code, might be conditional. So 
> that on Tuesdays, A is a class, the rest of the week it's the name of a 
> module.

But that situation is hardly *static*, so you can't blame a
static type checker for not coping with it.

-- 
Greg



More information about the Python-list mailing list