Skip to content

Add type hints (stub files) and py.typed marker#627

Closed
smheidrich wants to merge 1 commit intobinaryornot:mainfrom
smheidrich:add-type-hints
Closed

Add type hints (stub files) and py.typed marker#627
smheidrich wants to merge 1 commit intobinaryornot:mainfrom
smheidrich:add-type-hints

Conversation

@smheidrich
Copy link
Copy Markdown

Using stub files instead of inline annotations to maintain Python 2 compatibility.

Fixes #626.

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
@audreyfeldroy audreyfeldroy mentioned this pull request Mar 7, 2026
3 tasks
@smheidrich
Copy link
Copy Markdown
Author

Superseded by #643.

@smheidrich smheidrich closed this Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Type hints for public API

1 participant