Update type annotations (#3322)

* refactor: update Callable type hint

* refactor: update type annotations for hooks
This commit is contained in:
David Culley 2024-07-26 12:57:25 +02:00 committed by GitHub
parent 6c0857395f
commit 363a52526e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 54 additions and 42 deletions

View file

@ -8,7 +8,8 @@ import os
import pathlib
import sys
import traceback
from typing import TYPE_CHECKING, Any, Callable, Union
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, Union
from anki._vendor import stringcase # type: ignore

View file

@ -4,9 +4,9 @@
from __future__ import annotations
import re
from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence
from re import Match
from typing import TYPE_CHECKING, Any, Callable, Union
from typing import TYPE_CHECKING, Any, Union
if TYPE_CHECKING:
import anki._backend

View file

@ -9,7 +9,8 @@ from __future__ import annotations
import io
import os
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import requests
from requests import Response

View file

@ -1,8 +1,8 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from collections.abc import Sequence
from typing import Any, Callable, Type, Union
from collections.abc import Callable, Sequence
from typing import Any, Type, Union
import anki
from anki.collection import Collection

View file

@ -8,8 +8,7 @@ import pprint
import re
import sys
import time
from collections.abc import Sequence
from typing import Callable
from collections.abc import Callable, Sequence
from anki import media_pb2
from anki._legacy import DeprecatedNamesMixin, deprecated_keywords

View file

@ -3,7 +3,8 @@
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Callable
from collections.abc import Callable
from typing import TYPE_CHECKING, Any
import anki.collection
import anki.models

View file

@ -13,10 +13,10 @@ import subprocess
import sys
import tempfile
import time
from collections.abc import Iterable, Iterator
from collections.abc import Callable, Iterable, Iterator
from contextlib import contextmanager
from hashlib import sha1
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any
from anki._legacy import DeprecatedNamesMixinForModule
from anki.dbproxy import DBProxy

View file

@ -4,7 +4,8 @@
import copy
import os
import time
from typing import Callable, Dict
from collections.abc import Callable
from typing import Dict
import pytest

View file

@ -137,7 +137,9 @@ prefix = """\
from __future__ import annotations
from typing import Any, Callable, Sequence
from collections.abc import Callable, Sequence
from typing import Any
import anki
import anki.hooks
from anki.cards import Card

View file

@ -5,8 +5,8 @@ from __future__ import annotations
import os
import sys
from collections.abc import Callable
from ctypes import CDLL, CFUNCTYPE, c_bool, c_char_p
from typing import Callable
import aqt
import aqt.utils

View file

@ -3,7 +3,7 @@
from __future__ import annotations
from typing import Callable
from collections.abc import Callable
import aqt.editor
import aqt.forms

View file

@ -11,12 +11,12 @@ import os
import re
import zipfile
from collections import defaultdict
from collections.abc import Iterable, Sequence
from collections.abc import Callable, Iterable, Sequence
from concurrent.futures import Future
from dataclasses import dataclass
from datetime import datetime
from pathlib import Path
from typing import IO, Any, Callable, Union
from typing import IO, Any, Union
from urllib.parse import parse_qs, urlparse
from zipfile import ZipFile

View file

@ -6,8 +6,8 @@ from __future__ import annotations
import json
import math
import re
from collections.abc import Sequence
from typing import Any, Callable
from collections.abc import Callable, Sequence
from typing import Any
import aqt
import aqt.browser

View file

@ -3,7 +3,7 @@
from __future__ import annotations
from typing import Callable
from collections.abc import Callable
import aqt
from anki.cards import Card, CardId

View file

@ -6,7 +6,8 @@ from __future__ import annotations
import json
import re
import time
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import aqt.browser
from anki.cards import Card

View file

@ -2,9 +2,8 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from enum import Enum, auto
from typing import Callable
from anki.collection import SearchNode
from aqt.theme import ColoredIcon

View file

@ -3,8 +3,8 @@
from __future__ import annotations
import time
from collections.abc import Sequence
from typing import Any, Callable
from collections.abc import Callable, Sequence
from typing import Any
import aqt
import aqt.browser

View file

@ -2,8 +2,8 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations
from collections.abc import Sequence
from typing import Any, Callable
from collections.abc import Callable, Sequence
from typing import Any
import aqt
import aqt.browser

View file

@ -14,9 +14,10 @@ import urllib.error
import urllib.parse
import urllib.request
import warnings
from collections.abc import Callable
from enum import Enum
from random import randrange
from typing import Any, Callable, Match, cast
from typing import Any, Match, cast
import bs4
import requests

View file

@ -11,10 +11,10 @@ import re
import sys
import threading
import traceback
from collections.abc import Callable
from dataclasses import dataclass
from errno import EPROTOTYPE
from http import HTTPStatus
from typing import Callable
import flask
import flask_cors

View file

@ -4,9 +4,10 @@
from __future__ import annotations
import time
from collections.abc import Callable
from concurrent.futures import Future
from datetime import datetime
from typing import Any, Callable
from typing import Any
import aqt
import aqt.forms

View file

@ -3,8 +3,9 @@
from __future__ import annotations
from collections.abc import Callable
from concurrent.futures._base import Future
from typing import Any, Callable, Generic, Protocol, TypeVar, Union
from typing import Any, Generic, Protocol, TypeVar, Union
import aqt
import aqt.gui_hooks

View file

@ -2,8 +2,9 @@
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, Callable
from typing import Any
import aqt
import aqt.operations

View file

@ -7,7 +7,8 @@
import os
import sys
import traceback
from typing import Callable, TypeVar, Union
from collections.abc import Callable
from typing import TypeVar, Union
try:
import PyQt6

View file

@ -11,10 +11,11 @@ import sys
import time
import wave
from abc import ABC, abstractmethod
from collections.abc import Callable
from concurrent.futures import Future
from operator import itemgetter
from pathlib import Path
from typing import Any, Callable, cast
from typing import Any, cast
from markdown import markdown

View file

@ -3,7 +3,7 @@
from __future__ import annotations
from typing import Callable
from collections.abc import Callable
import aqt
import aqt.forms

View file

@ -4,8 +4,8 @@
from __future__ import annotations
import os
from collections.abc import Callable
from concurrent.futures import Future
from typing import Callable
import aqt
import aqt.main

View file

@ -9,10 +9,11 @@ See QueryOp() and CollectionOp() for higher-level routines.
from __future__ import annotations
from collections.abc import Callable
from concurrent.futures import Future
from concurrent.futures.thread import ThreadPoolExecutor
from threading import Lock, current_thread, main_thread
from typing import Any, Callable
from typing import Any
import aqt
from anki.collection import Progress

View file

@ -7,8 +7,8 @@ import enum
import os
import re
import subprocess
from collections.abc import Callable
from dataclasses import dataclass
from typing import Callable
import anki.lang
import aqt

View file

@ -9,10 +9,10 @@ import re
import shutil
import subprocess
import sys
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from functools import partial, wraps
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable, Literal, Union
from typing import TYPE_CHECKING, Any, Literal, Union
from send2trash import send2trash

View file

@ -7,9 +7,9 @@ import dataclasses
import json
import re
import sys
from collections.abc import Sequence
from collections.abc import Callable, Sequence
from enum import Enum
from typing import TYPE_CHECKING, Any, Callable, cast
from typing import TYPE_CHECKING, Any, cast
import anki
import anki.lang