Add type hints (stub files) and py.typed marker#627
Closed
smheidrich wants to merge 1 commit intobinaryornot:mainfrom
Closed
Add type hints (stub files) and py.typed marker#627smheidrich wants to merge 1 commit intobinaryornot:mainfrom
smheidrich wants to merge 1 commit intobinaryornot:mainfrom
Conversation
audreyfeldroy
added a commit
that referenced
this pull request
Mar 7, 2026
…d comes out is_binary() and get_starting_chunk() accept str, bytes, and Path, matching what Python's open() already handles. is_binary_string() takes bytes, _compute_features() takes bytes and returns list[float], and the decision tree's is_binary() takes list[float]. Resolves #626 (type hints for public API). Supersedes #627 (stub files, no longer needed since Python 2 was dropped). Addresses #628 (pathlib.Path support, which already worked but is now documented in the types). Key design decisions: - Inline annotations instead of .pyi stubs, since the project is Python 3.12+ - str | bytes | Path rather than os.PathLike[str] to match how people actually call the function (pathlib.Path, not custom PathLike objects) - No int (file descriptors): technically works via open() but no demonstrated use case and no error handling for bad fds
Author
|
Superseded by #643. |
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.
Using stub files instead of inline annotations to maintain Python 2 compatibility.
Fixes #626.