DinoTools / python-ssdeep

Python wrapper for ssdeep fuzzy hashing library
GNU Lesser General Public License v3.0
152 stars 30 forks source link

Add type stubs #38

Closed teskje closed 2 years ago

teskje commented 6 years ago

It would be nice to have type stubs shipped with the ssdeep Python package to enable static type checking with mypy.

Is this something you are interested in? If so I would be willing to prepare a PR for this.

phibos commented 5 years ago

Looks like we have to drop support for Python < 3.5 for type hints. PEP 484 -- Type Hints. Am I right?

Would this also improve the execution speed or is it only for static type checking?

thavelick commented 2 years ago

@ra-kete Hi, I've created stubs for this project:

By running pip install ssdeep-stubs you should be able to use ssdeep with mypy.

@phibos - You can distribute mypy stubs without breaking compatibility with older version of python. You'd simply distribute type annotation (*.pyi) files alongside your existing .py files. Earlier versions of python will just ignore these. But for now, mypy users can just use the stub package I've provided.

phibos commented 2 years ago

@thavelick thanks for your work. Any reason why we should use stub files instead of type hinting in the source?

thavelick commented 2 years ago

I can't think of a good reason. I think mypy just makes it possible to distribute stubs separately in case package maintainers don't want to do it. I probably should've just submitted a PR, but I actually found this issue after I had everything pretty much ready to go. At any rate I can deprecate my package if this project ends up adding annotations directly

mimi89999 commented 2 years ago

Any reason why we should use stub files instead of type hinting in the source?

That would require dropping support for old Python releases, but I doubt that anybody cares about them.

phibos commented 2 years ago

Any reason why we should use stub files instead of type hinting in the source?

That would require dropping support for old Python releases, but I doubt that anybody cares about them.

@mimi89999 I think you are right. We can drop it in the next release.

phibos commented 2 years ago

I have added type hints. Feel free to test and please report if something is missing.