From 77a53a6834d6500bf1a1292d536312535ff37e1f Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Wed, 10 Aug 2022 16:46:00 -0700 Subject: [PATCH] Update dependencies Includes changes from pyupgrade --- .pre-commit-config.yaml | 14 +++++++------- comicapi/comicarchive.py | 12 ++++++------ comicapi/filenameparser.py | 3 ++- comicapi/utils.py | 3 ++- comictaggerlib/coverimagewidget.py | 4 ++-- comictaggerlib/imagefetcher.py | 8 ++++---- comictaggerlib/issueidentifier.py | 2 +- comictaggerlib/settings.py | 3 ++- comictaggerlib/taggerwindow.py | 5 +++-- requirements-speedup.txt | 2 +- requirements.txt | 2 +- tests/conftest.py | 3 ++- 12 files changed, 33 insertions(+), 28 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a172a0d..5907ff3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ exclude: ^scripts repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.2.0 + rev: v4.3.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -10,7 +10,7 @@ repos: - id: name-tests-test - id: requirements-txt-fixer - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.1 + rev: v2.0.0 hooks: - id: setup-cfg-fmt - repo: https://github.com/PyCQA/isort @@ -19,12 +19,12 @@ repos: - id: isort args: [--af,--add-import, 'from __future__ import annotations'] - repo: https://github.com/asottile/pyupgrade - rev: v2.32.1 + rev: v2.37.3 hooks: - id: pyupgrade args: [--py39-plus] - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black - repo: https://github.com/PyCQA/autoflake @@ -33,12 +33,12 @@ repos: - id: autoflake args: [-i] - repo: https://github.com/PyCQA/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 - additional_dependencies: [flake8-encodings, flake8-warnings, flake8-builtins, flake8-eradicate, flake8-length, flake8-print] + additional_dependencies: [flake8-encodings, flake8-warnings, flake8-builtins, flake8-length, flake8-print] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.960 + rev: v0.971 hooks: - id: mypy additional_dependencies: [types-setuptools, types-requests] diff --git a/comicapi/comicarchive.py b/comicapi/comicarchive.py index ed7516c..b01eff3 100644 --- a/comicapi/comicarchive.py +++ b/comicapi/comicarchive.py @@ -114,7 +114,7 @@ class SevenZipArchiver(UnknownArchiver): return False def read_file(self, archive_file: str) -> bytes: - data = bytes() + data = b"" try: with py7zr.SevenZipFile(self.path, "r") as zf: data = zf.read(archive_file)[archive_file].read() @@ -422,7 +422,7 @@ class RarArchiver(UnknownArchiver): rarc = self.get_rar_obj() if rarc is None: - return bytes() + return b"" tries = 0 while tries < 7: @@ -665,7 +665,7 @@ class FolderArchiver(UnknownArchiver): class ComicArchive: - logo_data = bytes() + logo_data = b"" class ArchiveType: SevenZip, Zip, Rar, Folder, Pdf, Unknown = list(range(6)) @@ -853,13 +853,13 @@ class ComicArchive: return retcode def get_page(self, index: int) -> bytes: - image_data = bytes() + image_data = b"" filename = self.get_page_name(index) if filename: try: - image_data = self.archiver.read_file(filename) or bytes() + image_data = self.archiver.read_file(filename) or b"" except Exception: logger.error("Error reading in page %d. Substituting logo page.", index) image_data = ComicArchive.logo_data @@ -1033,7 +1033,7 @@ class ComicArchive: raw_cix = self.archiver.read_file(self.ci_xml_filename) or b"" except Exception as e: logger.error("Error reading in raw CIX! for %s: %s", self.path, e) - raw_cix = bytes() + raw_cix = b"" return raw_cix def write_cix(self, metadata: GenericMetadata) -> bool: diff --git a/comicapi/filenameparser.py b/comicapi/filenameparser.py index 9b1d86f..0d37b76 100644 --- a/comicapi/filenameparser.py +++ b/comicapi/filenameparser.py @@ -24,7 +24,8 @@ import logging import os import re from operator import itemgetter -from typing import Callable, Match, TypedDict +from re import Match +from typing import Callable, TypedDict from urllib.parse import unquote from text2digits import text2digits diff --git a/comicapi/utils.py b/comicapi/utils.py index 5d18724..ae376ca 100644 --- a/comicapi/utils.py +++ b/comicapi/utils.py @@ -21,8 +21,9 @@ import os import pathlib import unicodedata from collections import defaultdict +from collections.abc import Mapping from shutil import which # noqa: F401 -from typing import Any, Mapping +from typing import Any import pycountry import thefuzz.fuzz diff --git a/comictaggerlib/coverimagewidget.py b/comictaggerlib/coverimagewidget.py index bfc2de3..4f7b93c 100644 --- a/comictaggerlib/coverimagewidget.py +++ b/comictaggerlib/coverimagewidget.py @@ -113,7 +113,7 @@ class CoverImageWidget(QtWidgets.QWidget): self.page_loader = None self.imageIndex = -1 self.imageCount = 1 - self.imageData = bytes() + self.imageData = b"" self.btnLeft.setIcon(QtGui.QIcon(ComicTaggerSettings.get_graphic("left.png"))) self.btnRight.setIcon(QtGui.QIcon(ComicTaggerSettings.get_graphic("right.png"))) @@ -136,7 +136,7 @@ class CoverImageWidget(QtWidgets.QWidget): self.page_loader = None self.imageIndex = -1 self.imageCount = 1 - self.imageData = bytes() + self.imageData = b"" def clear(self) -> None: self.reset_widget() diff --git a/comictaggerlib/imagefetcher.py b/comictaggerlib/imagefetcher.py index d64cfe0..b4c55f3 100644 --- a/comictaggerlib/imagefetcher.py +++ b/comictaggerlib/imagefetcher.py @@ -97,14 +97,14 @@ class ImageFetcher: # if we found it, just emit the signal asap if image_data: ImageFetcher.image_fetch_complete(QtCore.QByteArray(image_data)) - return bytes() + return b"" # didn't find it. look online self.nam.finished.connect(self.finish_request) self.nam.get(QtNetwork.QNetworkRequest(QtCore.QUrl(url))) # we'll get called back when done... - return bytes() + return b"" def finish_request(self, reply: QtNetwork.QNetworkReply) -> None: # read in the image data @@ -159,10 +159,10 @@ class ImageFetcher: row = cur.fetchone() if row is None: - return bytes() + return b"" filename = row[0] - image_data = bytes() + image_data = b"" try: with open(filename, "rb") as f: diff --git a/comictaggerlib/issueidentifier.py b/comictaggerlib/issueidentifier.py index 264d698..385cbf6 100644 --- a/comictaggerlib/issueidentifier.py +++ b/comictaggerlib/issueidentifier.py @@ -157,7 +157,7 @@ class IssueIdentifier: cropped_im = im.crop((int(w / 2), 0, w, h)) except Exception: logger.exception("cropCover() error") - return bytes() + return b"" output = io.BytesIO() cropped_im.save(output, format="PNG") diff --git a/comictaggerlib/settings.py b/comictaggerlib/settings.py index 0ce6b65..baab556 100644 --- a/comictaggerlib/settings.py +++ b/comictaggerlib/settings.py @@ -22,7 +22,8 @@ import pathlib import platform import sys import uuid -from typing import Iterator, TextIO, no_type_check +from collections.abc import Iterator +from typing import TextIO, no_type_check from comicapi import utils diff --git a/comictaggerlib/taggerwindow.py b/comictaggerlib/taggerwindow.py index e5be611..b7467dc 100644 --- a/comictaggerlib/taggerwindow.py +++ b/comictaggerlib/taggerwindow.py @@ -26,7 +26,8 @@ import pprint import re import sys import webbrowser -from typing import Any, Callable, Iterable, cast +from collections.abc import Iterable +from typing import Any, Callable, cast from urllib.parse import urlparse import natsort @@ -1854,7 +1855,7 @@ Have fun! logger.error("Failed to load metadata for %s: %s", ca.path, e) image_data = ca.get_page(cover_idx) self.atprogdialog.set_archive_image(image_data) - self.atprogdialog.set_test_image(bytes()) + self.atprogdialog.set_test_image(b"") QtCore.QCoreApplication.processEvents() if self.atprogdialog.isdone: diff --git a/requirements-speedup.txt b/requirements-speedup.txt index 83b4bff..0833881 100644 --- a/requirements-speedup.txt +++ b/requirements-speedup.txt @@ -1 +1 @@ -thefuzz[speedup]>=0.19.0 \ No newline at end of file +thefuzz[speedup]>=0.19.0 diff --git a/requirements.txt b/requirements.txt index 82c4d08..0084ebd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ beautifulsoup4 >= 4.1 importlib_metadata natsort>=8.1.0 pathvalidate -pillow>=4.3.0 +pillow>=9.1.0 py7zr pycountry requests==2.* diff --git a/tests/conftest.py b/tests/conftest.py index 654357a..2fcdc8d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,8 @@ import datetime import io import shutil import unittest.mock -from typing import Any, Generator +from collections.abc import Generator +from typing import Any import pytest import requests