From 98b1e7d37fb9b7b067f85d59b97cc8f5f38a42d9 Mon Sep 17 00:00:00 2001 From: Johannes Buchner Date: Sun, 26 May 2024 20:22:07 +0200 Subject: [PATCH] make mypy happy, update CI --- .github/workflows/testing.yml | 2 +- imagehash/__init__.py | 5 ++--- tests/test_hex_conversions_multihash.py | 3 ++- tests/test_readme.py | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 5fdd5d4..b38dfce 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -28,7 +28,7 @@ jobs: run: echo "DATE=$(date +'%Y%m')" >> $GITHUB_ENV - name: Conda download cache id: myconda-download-cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: /usr/share/miniconda/pkgs/ key: ${{ matrix.python-version }}-conda-${{ env.DATE }}-${{ env.CACHE_NUMBER }} diff --git a/imagehash/__init__.py b/imagehash/__init__.py index 22123a9..531891e 100644 --- a/imagehash/__init__.py +++ b/imagehash/__init__.py @@ -34,6 +34,7 @@ import numpy from PIL import Image, ImageFilter + try: ANTIALIAS = Image.Resampling.LANCZOS except AttributeError: @@ -635,7 +636,7 @@ def _find_all_segments(pixels, segment_threshold, min_segment_size): def crop_resistant_hash( image, # type: Image.Image - hash_func=None, # type: HashFunc + hash_func=dhash, # type: HashFunc limit_segments=None, # type: int | None segment_threshold=128, # type: int min_segment_size=500, # type: int @@ -659,8 +660,6 @@ def crop_resistant_hash( :param min_segment_size: Minimum number of pixels for a hashable segment :param segmentation_image_size: Size which the image is resized to before segmentation """ - if hash_func is None: - hash_func = dhash orig_image = image.copy() # Convert to gray scale and resize diff --git a/tests/test_hex_conversions_multihash.py b/tests/test_hex_conversions_multihash.py index cc55cb9..07295e7 100644 --- a/tests/test_hex_conversions_multihash.py +++ b/tests/test_hex_conversions_multihash.py @@ -1,8 +1,9 @@ -from __future__ import (absolute_import, division, print_function) +from __future__ import absolute_import, division, print_function import unittest import imagehash + from .utils import TestImageHash diff --git a/tests/test_readme.py b/tests/test_readme.py index 0a4b60d..3d7a0d7 100644 --- a/tests/test_readme.py +++ b/tests/test_readme.py @@ -1,4 +1,5 @@ import os + import six