typing icon indicating copy to clipboard operation
typing copied to clipboard

Support `sys.implementation.name` as feature switch for stubs

Open cdce8p opened this issue 2 years ago • 0 comments

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: ...

cdce8p avatar Jan 28 '23 10:01 cdce8p