python / python/mypy

Use importlib.resources to load typeshed resources

Open
#21,861 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature topic-developer
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Feature

Use importlib.resources to load the typeshed resources, instead of finding them relative to __file__ in build.py.

Pitch

In android, we build all python binaries into self-contained zip files. So __file__ resolves to a path in a zip, and reading files relative to it fails. importlib.resources can handle both the zip case and the directory case transparently.

Currently we are using --custom-typeshed-dir as a workaround. (Code not public yet)

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 in build.py, where typeshed resources are currently found relative to file. Replace that resource-loading approach with importlib.resources, then verify that loading works both from a directory and from a self-contained zip, which is the expected definition of done.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.