typing
typing copied to clipboard
Support `sys.implementation.name` as feature switch for stubs
Problem
Sometimes, attributes and variables are only defined for a specific implementation.
E.g. I recently saw that PyPy has a sys.pypy_version_info variable.
At the moment, type checkers only support sys.version_info and sys.platform checks AFAIK.^1
Idea
Add support for sys.implementation.name^2 checks.
import sys
if sys.implementation.name == "pypy":
pypy_version_info: ...