feat: add py.typed marker so mypy uses the shipped type hints (#234) - #457
Closed
keel-code-review-tc[bot] wants to merge 3 commits into
Closed
feat: add py.typed marker so mypy uses the shipped type hints (#234)#457keel-code-review-tc[bot] wants to merge 3 commits into
keel-code-review-tc[bot] wants to merge 3 commits into
Conversation
Broly Security ScanNote ✅ Clean scan Note Re-scan this PR anytime with
|
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #234
Describe your changes
togetheris a fully annotated package —[tool.mypy]runs withstrict = true— but it ships no PEP 561py.typedmarker, so type checkers treat it as untyped. Anyone running mypy against a project that imports it gets:The only workaround today is a per-project
follow_untyped_importsoverride, repeated in every consumer. Adding the marker tells mypy the inline annotations that already exist are authoritative, so downstream users get real type checking against this SDK instead ofAny.What's in this PR:
src/together/py.typed— the marker file, inside the package so it lands next to__init__.pyin the installed distribution. Its contents are ignored by the spec; the file's presence is the signal.tests/unit/test_py_typed.py— asserts the marker is present relative to the importedtogethermodule, not relative to the repo tree. That distinction matters: resolving it throughtogether.__file__means the test fails if the marker is ever dropped from the built wheel, which is the failure mode that would silently bring the original error back for users while looking fine in-tree.Worth noting
tests/unit/test_imports.pyalready skips*.typedfiles when walkingsrc/together/*, so the marker was anticipated there and needs no change to that test.One thing for a maintainer to confirm before merge.
[tool.poetry]declares no explicitpackages, so Poetry auto-detectssrc/togetherand includes non-Python files found inside the package directory — which should carrypy.typedinto both the sdist and the wheel with no packaging change. I could not build a wheel here to prove it, so this is unverified rather than asserted. Please check the built artifact containstogether/py.typed(unzip -l dist/*.whl | grep py.typed). If it does not, the fix is an explicitincludeentry inpyproject.tomlscoped to both formats — happy to push that follow-up. The new test is what would catch this against an installed build.Authored by Keel via the GitHub API as a DRAFT pull request. It awaits human review and is gated by CI (the agent runs no tests locally). Do not merge without an approving human review.