Add 'py.typed'#69
Conversation
📝 WalkthroughWalkthroughThe pull request updates the package version from ChangesPackage Version Update
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~1 minute Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
94cdfb5 to
178152f
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pyproject.toml (1)
84-85:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winMissing package-data configuration to include py.typed file.
For PEP 561 compliance, the
py.typedmarker file must be included in the built distribution. Currently, the setuptools configuration lacks explicit directives to include non-Python files. By default, setuptools only packages.pyfiles, sopy.typedwill be excluded from the wheel/sdist, defeating the purpose of this PR.Add package-data configuration to ensure
py.typedis bundled:📦 Proposed fix to include py.typed in distribution
Add this section after line 85:
[tool.setuptools.packages.find] where = ["src"] + +[tool.setuptools.package-data] +"*" = ["py.typed"]Alternatively, use:
[tool.setuptools.packages.find] where = ["src"] + +[tool.setuptools] +include-package-data = trueRun the following script to verify whether
py.typedwould be included in the built package:#!/bin/bash # Description: Check if py.typed exists and verify setuptools will include it # Find py.typed file location echo "=== Searching for py.typed file ===" fd -t f '^py\.typed$' src/ # Check if package-data or include-package-data is configured echo -e "\n=== Checking for package-data configuration ===" rg -n 'package-data|include-package-data' pyproject.toml setup.py setup.cfg MANIFEST.in 2>/dev/null || echo "No package-data configuration found" # Verify what files would be included by setuptools (if setup.py exists) echo -e "\n=== Simulating package build to check included files ===" if [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then python -m pip install build 2>/dev/null || pip install build 2>/dev/null python -m build --sdist --wheel --outdir /tmp/build_check 2>&1 | head -20 # List contents of built wheel if successful if ls /tmp/build_check/*.whl 2>/dev/null; then echo -e "\n=== Contents of built wheel ===" unzip -l /tmp/build_check/*.whl 2>/dev/null | grep -E '(py\.typed|\.py$)' | head -30 fi fi🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pyproject.toml` around lines 84 - 85, The project is missing packaging directives to include the py.typed marker in the built distribution; update pyproject.toml to ensure py.typed is bundled by adding either an explicit package-data mapping or enabling include-package-data and providing a MANIFEST.in. Concretely, add a [tool.setuptools.package-data] section that maps your package(s) (the packages discovered under src) to ["py.typed"] or set [tool.setuptools] include-package-data = true and add a MANIFEST.in that contains "recursive-include src *py.typed" (or equivalent path), then rebuild to verify py.typed is present; reference the existing [tool.setuptools.packages.find] block to locate the packages that need the py.typed entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@pyproject.toml`:
- Around line 84-85: The project is missing packaging directives to include the
py.typed marker in the built distribution; update pyproject.toml to ensure
py.typed is bundled by adding either an explicit package-data mapping or
enabling include-package-data and providing a MANIFEST.in. Concretely, add a
[tool.setuptools.package-data] section that maps your package(s) (the packages
discovered under src) to ["py.typed"] or set [tool.setuptools]
include-package-data = true and add a MANIFEST.in that contains
"recursive-include src *py.typed" (or equivalent path), then rebuild to verify
py.typed is present; reference the existing [tool.setuptools.packages.find]
block to locate the packages that need the py.typed entry.
Merging this PR will not alter performance
Comparing Footnotes
|
Added in version v69.0.0: setuptools will attempt to include type information files by default in the distribution (.pyi and py.typed, as specified in PEP 561), as long as they are contained inside of a package directory (for the time being there is no automatic support for top-level .pyi files). source: https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html |
Reasoning: https://peps.python.org/pep-0561/#packaging-type-information
Linters like pylance in strict mode would not check for types if either stubs (pyi) or py.typed are not provided
Summary by CodeRabbit