meta-pytorch / meta-pytorch/data
Include `py.typed` marker file for mypy type hint compatibility
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.3k
- Forks
- 179
- Avg merge
- 6d 1h
- Merged PRs (30d)
- 2
Description
🚀 The feature
From what I can tell torchdata actually had type stubs but mypy won't pick it up because it is missing the py.typed marker file (see: https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-library-stubs-or-py-typed-marker)
The ask is to add py.typed to the package data similar to how torch does it so that projects using torchdata can have mypy recognize torchdata modules type hints.
Motivation, pitch
My project uses torchdata and also uses mypy for static type checking. Since mypy does not pick up torchdata's type stubs I get an error as:
mfive/datapipes/amzn/datakit.py:9:1: error: Skipping analyzing "torchdata.datapipes": module is installed, but missing library stubs or py.typed marker [import]
Alternatives
I could add a ignore-missing-imports in my mypy.ini file:
[mypy-torchdata.*]
ignore_missing_imports = True
But that means that all the torchdata related types will be typed as Any, hence not letting me enable checks like disallow_subclassing_any=True if I'm writing my own custom datapipe that subclasses torchdata.datapipes.iter.IterDataPipe.
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by inspecting torchdata's packaging configuration and compare its package-data handling with the linked PyTorch setup.py example. Add the py.typed marker to the distributed package data, then verify an installed torchdata package contains it and that mypy no longer reports the missing-stubs or py.typed-marker error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100