mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
use 3.7 annotations
This commit is contained in:
parent
8b94d69abc
commit
e7ea121196
8 changed files with 26 additions and 9 deletions
|
@ -1,5 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
import time
|
import time
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
@ -29,7 +32,7 @@ class Card:
|
||||||
lastIvl: Optional[int]
|
lastIvl: Optional[int]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, col: "anki.collection._Collection", id: Optional[int] = None
|
self, col: anki.collection._Collection, id: Optional[int] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
self.col = col
|
self.col = col
|
||||||
self.timerStarted = None
|
self.timerStarted = None
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import operator
|
import operator
|
||||||
|
@ -98,7 +100,7 @@ class DeckManager:
|
||||||
# Registry save/load
|
# Registry save/load
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
def __init__(self, col: "anki.storage._Collection") -> None:
|
def __init__(self, col: anki.storage._Collection) -> None:
|
||||||
self.col = col
|
self.col = col
|
||||||
self.decks = {}
|
self.decks = {}
|
||||||
self.dconf = {}
|
self.dconf = {}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
@ -80,7 +82,7 @@ class ModelManager:
|
||||||
# Saving/loading registry
|
# Saving/loading registry
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
def __init__(self, col: "anki.storage._Collection") -> None:
|
def __init__(self, col: anki.storage._Collection) -> None:
|
||||||
self.col = col
|
self.col = col
|
||||||
self.models = {}
|
self.models = {}
|
||||||
self.changed = False
|
self.changed = False
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
import anki # pylint: disable=unused-import
|
import anki # pylint: disable=unused-import
|
||||||
|
@ -17,7 +19,7 @@ from anki.utils import (
|
||||||
|
|
||||||
|
|
||||||
class Note:
|
class Note:
|
||||||
col: "anki.storage._Collection"
|
col: anki.storage._Collection
|
||||||
newlyAdded: bool
|
newlyAdded: bool
|
||||||
id: int
|
id: int
|
||||||
guid: str
|
guid: str
|
||||||
|
@ -32,7 +34,7 @@ class Note:
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
col: "anki.storage._Collection",
|
col: anki.storage._Collection,
|
||||||
model: Optional[NoteType] = None,
|
model: Optional[NoteType] = None,
|
||||||
id: Optional[int] = None,
|
id: Optional[int] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|
|
@ -7,6 +7,8 @@ A Python implementation of some backend commands.
|
||||||
Unimplemented commands will be forwarded on to the Rust backend.
|
Unimplemented commands will be forwarded on to the Rust backend.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Dict, Tuple
|
from typing import Any, Dict, Tuple
|
||||||
|
|
||||||
import anki # pylint: disable=unused-import
|
import anki # pylint: disable=unused-import
|
||||||
|
@ -14,7 +16,7 @@ import anki.backend_pb2 as pb
|
||||||
|
|
||||||
|
|
||||||
class PythonBackend:
|
class PythonBackend:
|
||||||
def __init__(self, col: "anki.storage._Collection"):
|
def __init__(self, col: anki.storage._Collection):
|
||||||
self.col = col
|
self.col = col
|
||||||
|
|
||||||
def run_command_bytes(self, input: bytes) -> bytes:
|
def run_command_bytes(self, input: bytes) -> bytes:
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import itertools
|
import itertools
|
||||||
import random
|
import random
|
||||||
|
@ -38,7 +40,7 @@ class Scheduler:
|
||||||
_burySiblingsOnAnswer = True
|
_burySiblingsOnAnswer = True
|
||||||
revCount: int
|
revCount: int
|
||||||
|
|
||||||
def __init__(self, col: "anki.storage._Collection") -> None:
|
def __init__(self, col: anki.storage._Collection) -> None:
|
||||||
self.col = col
|
self.col = col
|
||||||
self.queueLimit = 50
|
self.queueLimit = 50
|
||||||
self.reportLimit = 1000
|
self.reportLimit = 1000
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import gzip
|
import gzip
|
||||||
import io
|
import io
|
||||||
import json
|
import json
|
||||||
|
@ -35,7 +37,7 @@ class UnexpectedSchemaChange(Exception):
|
||||||
class Syncer:
|
class Syncer:
|
||||||
cursor: Optional[sqlite3.Cursor]
|
cursor: Optional[sqlite3.Cursor]
|
||||||
|
|
||||||
def __init__(self, col: "anki.storage._Collection", server=None) -> None:
|
def __init__(self, col: anki.storage._Collection, server=None) -> None:
|
||||||
self.col = col
|
self.col = col
|
||||||
self.server = server
|
self.server = server
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ tracked, so unused tags can only be removed from the list with a DB check.
|
||||||
This module manages the tag cache and tags for notes.
|
This module manages the tag cache and tags for notes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from typing import Callable, Dict, List, Tuple
|
from typing import Callable, Dict, List, Tuple
|
||||||
|
@ -23,7 +25,7 @@ class TagManager:
|
||||||
# Registry save/load
|
# Registry save/load
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
def __init__(self, col: "anki.storage._Collection") -> None:
|
def __init__(self, col: anki.storage._Collection) -> None:
|
||||||
self.col = col
|
self.col = col
|
||||||
self.tags: Dict[str, int] = {}
|
self.tags: Dict[str, int] = {}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue