feat: add py.typed marker for PEP 561 compliance#1530
feat: add py.typed marker for PEP 561 compliance#1530kalichiruvelli-art wants to merge 1 commit intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to make flaml PEP 561-compliant so type checkers (Pyright/Pylance/mypy) recognize it as a typed package by shipping a py.typed marker in the distribution.
Changes:
- Add
flaml/py.typedmarker file. - Add a
pyproject.tomlentry intended to includepy.typedas package data during packaging.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pyproject.toml | Adds setuptools package-data config for shipping flaml/py.typed. |
| flaml/py.typed | Adds the PEP 561 marker file to the package. |
| [tool.setuptools.package-data] | ||
| flaml = ["py.typed"] No newline at end of file |
There was a problem hiding this comment.
This [tool.setuptools.package-data] entry may not be applied in the current release/build pipeline, which runs python setup.py sdist bdist_wheel (see .github/workflows/CD.yml). Since setup.py currently only sets package_data for flaml.default, the built wheel may still omit flaml/py.typed, defeating the PEP 561 marker. Consider adding py.typed to package_data in setup.py (or switching packaging to a PEP 517/pyproject-based setuptools config) to ensure it is included in sdists/wheels.
|
@microsoft-github-policy-service agree |
Summary
Adds an empty
py.typedmarker file to theflaml/package directory as specified by PEP 561.Problem
Type checkers (Pyright, Pylance, mypy) treat
flamlas untyped because there is nopy.typedmarker, causing warnings like:Stub file not found for "flaml"(reportMissingTypeStubs)Fix
flaml/py.typedmarker file (zero bytes, no logic changes)[tool.setuptools.package-data]entry inpyproject.tomlso the file is included in the built distributionNo logic changes, no new dependencies.