How can I contribute better type annotations to pyperf?

0
0
Asked By MellowCedar42 On

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.

2 Answers

Answered By QuietMaple7 On

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.

Answered By BrightKite_58 On

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.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.