Closed adamtheturtle closed 10 months ago
ad 1: no, imagehash supports very old versions (python 2 was only removed very recently). ad 2: you would have to @ tag the person here who wrote that code.
To give additional guidance, as you may be able to see from previous issues, type checking has been somewhat of a headache for me. I wish it had been possible to keep a single script imagehash.py. It breaks the appeal of imagehash being a simple self-contained file that can be read and understood. TLDR: KISS.
Thank you for the response @JohannesBuchner . I will close, and in my project I have copied average_hash
to achieve type safety.
Create a directory with the following files:
Run the following:
See the following error:
The issue is that the type of
mean
isUnknown
topyright
.I see in the codebase that
mean
is typed asMeanFunc
.MeanFunc
is a type alias toCallable
, with the parameter and return types set conditionally.pyright
does not work well with those conditionals.I see two conditions which lead to the type inference difficulty:
https://github.com/JohannesBuchner/imagehash/blob/38005924fe9be17cfed145bbc6d83b09ef8be025/imagehash/__init__.py#L142-L147
https://github.com/JohannesBuchner/imagehash/blob/38005924fe9be17cfed145bbc6d83b09ef8be025/imagehash/__init__.py#L156-L161
I'm happy to contribute changes to this project to get
pyright
passing on my project, and I would like some guidance.For (1): Can this be removed? Python 3.6 has been EOL'd for a couple of years (EOL date 2021-12-23).
For (2): Can you give some insight into when the
TypeError
may be expected?