python / python/typing

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

Open
#1,339 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

topic: feature
Dominant language
Python
Stars
1.8k
Forks
302
Avg merge
23h
Merged PRs (30d)
8

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the typing repository and the issue's references to Python's sys.implementation.name and PEP 421. Determine where implementation-specific feature switches are specified or tested; done means checks such as sys.implementation.name == "pypy" are recognized so conditional definitions like pypy_version_info are handled correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.