tlsfuzzer / python-ecdsa

pure-python ECDSA signature/verification and ECDH key agreement
Other
905 stars 309 forks source link

Add type annotations #340

Open sumezulike opened 1 month ago

sumezulike commented 1 month ago

Adding typehints would greatly improve usability.

Without type annotations, IDE support is very limited and I often have to search through the code to figure out the exact types of a given attribute. Also static typechecking is obviously not possible, which I think is also pretty important for consistent code quality.

If that's an effort that would be appreciated, I would start by type-hinting the modules I currently use the most.

tomato42 commented 1 month ago

Python 2.6 and 2.7 are still very much supported by this project, and will remain so for at least the next year or so. As such, you'll need to add the type hints as comments, not inline. If that will help with your IDE: sure, go ahead. You can provide patches even on a function to function basis, as you work through them. Don't need to tackle the whole (public) API at once.

sumezulike commented 1 month ago

Could type stubs then be a better solution? Those shouldn't interfere with the old pythons afaik.

tomato42 commented 1 month ago

the issue is that you do have to remember to edit them and keep them updated... when type information is in a single file, then it's obvious and easy to do, when it's in separate file then it's easy to forget...

and if I do accept something into the repo, I generally intend to maintain it, can't realistically do it with this solution :face_with_diagonal_mouth:

sumezulike commented 1 month ago

Yeah, understandable... I'm not a huge fan of type stubs either. I'll figure out how much type comments help!