Open Matthias-Thul opened 3 years ago
Hmm, this seems to be happening because pytype doesn't recognize that decorator
returns the original function, so it can no longer tell that wrapper
is nested inside decorator_2
and therefore allowed to refer to the latter's TypeVars.
I assume that decorator
is more complicated in your actual code, but if you're able to annotate it as an identity function ((victim: T) -> T
), that would probably work.
Consider the following example
PyType
2021.07.19
fails withWhen removing the
decorator
applied to the innerwrapper
, PyType doesn't complain anymore. mypy0.910
is happy with either. This seems related to the closed issue https://github.com/google/pytype/issues/379.