How can I contribute better type annotations to pyperf?

August 28, 2026 2 answers
Asked by MellowCedar42
I recently started using pyperf to benchmark changes in an open-source project and include performance metrics with my pull request. While working with it, I noticed that several APIs produce unknown or incomplete types, including some fairly simple function parameters. I'm considering contributing improved type annotations, but I'm not sure whether the project generally accepts this kind of contribution or what the maintainers would expect. Is there an established issue tracker or preferred process for proposing typing improvements? I'm developing on Windows and currently use Pyrefly, though I'm willing to check compatibility with other type checkers such as mypy and ty.

Answers

BrightKite_58
Itโ€™s worth checking first, but improving the typing may be more involved than it looks. Pythonโ€™s type system has a lot of edge cases, and no type checker fully agrees on every feature yet. Some unknown or broad types can be difficult to eliminate completely, especially in a library that needs to work well across multiple checkers.

MellowCedar42: That makes sense for complicated parts of the API, but Iโ€™m also seeing unknown types on relatively simple parameters. Iโ€™ve run into similar, and sometimes worse, typing issues in other libraries where editor completion barely works, so I thought this might be a useful area to improve.

Reply to this answer
QuietMaple7
A good first step would be to open an issue asking whether the maintainers are interested in adding or improving annotations for the public API. You can also review the projectโ€™s existing issue tracker for related work or smaller tasks. Any proposed annotations should ideally be tested with several commonly used type checkers rather than only Pyrefly, since pyperf is a general-purpose library.

MellowCedar42: I can test the changes with Pyrefly, mypy, and ty to compare their behavior. Iโ€™ll look for the projectโ€™s issue tracker and check whether there is already an open discussion about typing.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions