python / python/typeshed

Adding platform information to stdlib/VERSIONS

Open
#11,260 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

project: policy
Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

It might be a good idea to add platform availability information to stdlib/VERSIONS, instead of using the sys.platform hack we're currently using in the source files. This has the same rationale for introducing VERSIONS in the first place:

  • Remove platform checks and the required indentation from stub files.
  • Enables clearer type checker messages (e.g. "Module does not exist on this platform", instead of "Item X doesn't exist in module Y")
  • Generally an unambiguous way of indicating that a module doesn't exist.
  • Edit: Collect all information about module availability in one place.

One way to do this is an HTTP/E-Mail header-like key/value syntax:

abc: 3.0-; platforms=linux,darwin
def: 3.7-3.10; platforms=!windows,!linux
ghi: 3.9-

This would allow future extension when type checkers are equipped to ignore unknown keys:

abc: 3.0-; header1=foo; header2=bar

Do we need a way do indicate that a certain platform only supports a certain module starting from a certain Linux version?

Contributor guide

Open the contributing guide

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 with stdlib/VERSIONS and the source files that currently use sys.platform checks. Review how module availability is represented there and how type checkers consume it. Define the platform key/value format, including version-specific platform support and handling of unknown keys; done means the proposal is specified well enough for implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.