pygit2 icon indicating copy to clipboard operation
pygit2 copied to clipboard

Type Annotations

Open tmr232 opened this issue 8 years ago • 6 comments

I was thinking of adding type annotations to some of the APIs to assist IDEs in parsing them and providing useful completion.

Since it currently does not exist in the code, I preferred asking before coding. Due to supporting both Python 2 and 3, I think the way to do it is to use syntax present here.

There are some drawbacks:

  1. Adding a new dependency - the typing package
  2. Annotation comments are not the prettiest thing

But if we only the do the required minimum, we get more clarity when using the library, and can also use mypy as a verification step for new code.

@jdavid what is your opinion?

tmr232 avatar May 09 '17 17:05 tmr232

+1 if integration with Travis is added

jdavid avatar May 15 '17 11:05 jdavid

Typing hints for the API are sorely missed and would be great to have. Please, add them as separate .pyi file(s) with Python 3 typing hints.

vistatest avatar Jun 20 '19 18:06 vistatest

We don't support Python 2 any more, so this should be easier. The minimum required version is Python 3.5

Anyway this should be contributed (PR), or funded (sponsored).

For reference, about .pyi files see https://mypy.readthedocs.io/en/stable/stubs.html

jdavid avatar Mar 07 '20 09:03 jdavid

If Python 2 is no longer supported - any reason to use stubs and not just add annotations to the code?

tmr232 avatar Mar 08 '20 20:03 tmr232

Any status update on this? Would a PR that annotate the code be accepted?

mg-christian-esser avatar Nov 01 '21 16:11 mg-christian-esser

Yes, but instead of 1 big PR, I'd prefer a number of smaller PRs

(Today the minimum supported version of Python is 3.7)

jdavid avatar Nov 03 '21 08:11 jdavid

Since this issue was opened type hints have been added to the C extension. For further improvements please open a PR.

jdavid avatar Jan 11 '24 10:01 jdavid