olefile icon indicating copy to clipboard operation
olefile copied to clipboard

Type hints

Open radarhere opened this issue 1 year ago • 2 comments

Hi. In case you were interested in adding type hints in this repository, just letting you know - I recently added type hints for olefile to typeshed - https://github.com/python/typeshed/pull/11416. If you wanted to make use of that, it would give you a good head start on that endeavour.

The stubs package can be seen at https://pypi.org/project/types-olefile/

radarhere avatar Feb 18 '24 20:02 radarhere

Hi @radarhere, thanks a lot for all this work! What would you suggest to do within olefile?

decalage2 avatar Feb 20 '24 12:02 decalage2

The simplest option would be to just

  • add the relevant *.pyi files alongside the existing *.py files as per https://peps.python.org/pep-0484/#storing-and-distributing-stub-files, and
  • add a py.typed file as per https://peps.python.org/pep-0561/#packaging-type-information

If instead you were interested in being more thorough and running a tool like https://mypy-lang.org/ over the code, then you'd want to update your code with the type arguments, e.g. replacing def build_storage_tree(self): with def build_storage_tree(self) -> None:, as mypy would want you to make other changes within the body of the code.

radarhere avatar Feb 21 '24 10:02 radarhere