From 518cc44267034031d3b0681d789b464c1139f388 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 25 Dec 2019 09:19:57 +1000 Subject: [PATCH] add a few type hints --- anki/decks.py | 3 ++- anki/notes.py | 6 +++++- anki/tags.py | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/anki/decks.py b/anki/decks.py index 041d98d49..97916b4b2 100644 --- a/anki/decks.py +++ b/anki/decks.py @@ -8,6 +8,7 @@ import operator import unicodedata from typing import Any, Dict, List, Optional, Set, Tuple, Union +import anki # pylint: disable=unused-import from anki.consts import * from anki.errors import DeckRenameError from anki.hooks import runHook @@ -98,7 +99,7 @@ class DeckManager: # Registry save/load ############################################################# - def __init__(self, col) -> None: + def __init__(self, col: "anki.storage._Collection") -> None: self.col = col self.decks = {} self.dconf = {} diff --git a/anki/notes.py b/anki/notes.py index 26055a2aa..5b26249dc 100644 --- a/anki/notes.py +++ b/anki/notes.py @@ -4,6 +4,7 @@ from typing import Any, List, Optional, Tuple +import anki # pylint: disable=unused-import from anki.utils import ( fieldChecksum, guid64, @@ -19,7 +20,10 @@ class Note: tags: List[str] def __init__( - self, col, model: Optional[Any] = None, id: Optional[int] = None + self, + col: "anki.storage._Collection", + model: Optional[Any] = None, + id: Optional[int] = None, ) -> None: assert not (model and id) self.col = col diff --git a/anki/tags.py b/anki/tags.py index d0730b381..33c528131 100644 --- a/anki/tags.py +++ b/anki/tags.py @@ -14,6 +14,7 @@ import json import re from typing import Callable, Dict, List, Tuple +import anki # pylint: disable=unused-import from anki.hooks import runHook from anki.utils import ids2str, intTime @@ -23,7 +24,7 @@ class TagManager: # Registry save/load ############################################################# - def __init__(self, col) -> None: + def __init__(self, col: "anki.storage._Collection") -> None: self.col = col self.tags: Dict[str, int] = {}