google / google/flatbuffers

[Python] Incorrect usage of py.typed marker

Open
#9,223 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
26.5k
Forks
3.7k
PR merge metrics
No merged PRs in 30d

Description

The Python library has a [py.typed](https://github.com/google/flatbuffers/blob/master/python/py.typed) file, but it's usage is completely wrong. This then also makes generated type stubs useless.

1. The library has absolutely no type annotations.
2. The marker is in the wrong place. It should be moved to the flatbuffers/ subdirectory, so that it becomes included in the package.

To quote https://typing.python.org/en/latest/spec/distributing.html#packaging-type-information

> Package maintainers who wish to support type checking of their code MUST add a marker file named py.typed to their package supporting typing.

Currently, the two wrongs make a right. py.typed would indicate that package should support type checking (which it doesn't due to missing hints), but it's placed wrong (it's not in the _package_).

Either py.typed should be removed (boo), or the library should be given proper type hints and py.typed should be moved. Given that latest no-EOL version of Python is 3.10, would it be ok to raise a PR using modern type hints, or what would be the target lowest supported Python version?

Contributor guide

Open the contributing guide

Research direction

Start by inspecting python/py.typed and the flatbuffers/ package layout, then review the generated type stubs and the Python support policy. The issue is resolved when the project decides whether to remove the marker or add proper type hints, places py.typed in the package if retained, and establishes the lowest supported Python version.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.