Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing stubs #161

Closed
wants to merge 4 commits into from
Closed

Conversation

SpangleLabs
Copy link

This should close #151, type stubs for all the methods and classes in imagehash.py

@coveralls
Copy link

coveralls commented May 23, 2022

Coverage Status

Coverage increased (+0.04%) to 89.535% when pulling 493bc2d on SpangleLabs:typing-stubs into 0abd487 on JohannesBuchner:master.

@Avasam
Copy link

Avasam commented Aug 29, 2022

  • Callable should come from collections.abc
  • In type stubs (and Python 3.10+), | is preferable over Union and Optional (ie: int | None)
  • built-in generics (list, dict, tuple, set) is preferable over importing them from typing (except in type aliases, in base classes, and for arbitrary length tuples (Tuple[int, ...]))
  • I think np.bool_ should be np.int32
  • npt.NDArray is missing a type argument, which results in a partially Unknown type
    image
    image

But, given the above comments from @JohannesBuchner , I get the feeling you may have to use comment annotations for this to be accepted. See https://mypy.readthedocs.io/en/stable/python2.html

#151 (comment)

imagehash is trying to support python2

#151 (comment)

I am wondering how to do this with the least amount of future maintenance effort. I am worried that the stub file may become outdated if not care is taken.

@SpangleLabs
Copy link
Author

Thank you @Avasam !

@SpangleLabs SpangleLabs closed this Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Please add type hints or type stubs
3 participants