Skip to content

Commit

Permalink
Merge branch 'main' into Empty2
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur-Milchior authored Aug 26, 2024
2 parents d6a0294 + a179da3 commit f7fb0e4
Show file tree
Hide file tree
Showing 38 changed files with 619 additions and 141 deletions.
9 changes: 1 addition & 8 deletions .buildkite/linux/docker/Dockerfile.amd64
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:10-slim
FROM debian:11-slim

ARG DEBIAN_FRONTEND="noninteractive"

Expand Down Expand Up @@ -53,13 +53,6 @@ RUN mkdir -p /etc/buildkite-agent/hooks && chown -R user /etc/buildkite-agent
COPY buildkite.cfg /etc/buildkite-agent/buildkite-agent.cfg
COPY environment /etc/buildkite-agent/hooks/environment

# Available in Debian 11 as ninja-build, but we're building with Debian 10
RUN curl -LO https://github.com/ninja-build/ninja/releases/download/v1.11.1/ninja-linux.zip \
&& unzip ninja-linux.zip \
&& chmod +x ninja \
&& mv ninja /usr/bin \
&& rm ninja-linux.zip

RUN mkdir /state/rust && chown user /state/rust

USER user
Expand Down
15 changes: 8 additions & 7 deletions .dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
"target",
".mypy_cache",
"extra",
"ts/.svelte-kit"
"ts/.svelte-kit",
"ts/vite.config.ts.timestamp*"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.85.1.wasm",
"https://plugins.dprint.dev/json-0.17.4.wasm",
"https://plugins.dprint.dev/markdown-0.15.3.wasm",
"https://plugins.dprint.dev/toml-0.5.4.wasm",
"https://plugins.dprint.dev/prettier-0.13.0.json@dc5d12b7c1bf1a4683eff317c2c87350e75a5a3dfcc127f3d5628931bfb534b1",
"https://plugins.dprint.dev/disrupted/css-0.2.2.wasm"
"https://plugins.dprint.dev/typescript-0.91.6.wasm",
"https://plugins.dprint.dev/json-0.19.3.wasm",
"https://plugins.dprint.dev/markdown-0.17.6.wasm",
"https://plugins.dprint.dev/toml-0.6.2.wasm",
"https://plugins.dprint.dev/prettier-0.46.1.json@e5bd083088a8dfc6e5ce2d3c9bee81489b065bd5345ef55b59f5d96627928b7a",
"https://plugins.dprint.dev/disrupted/css-0.2.3.wasm"
]
}
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
[workspace.package]
version = "0.0.0"
authors = ["Ankitects Pty Ltd and contributors <https://help.ankiweb.net>"]
edition = "2021"
license = "AGPL-3.0-or-later"
rust-version = "1.65"
edition = "2021"

[workspace]
members = [
"build/configure",
"build/ninja_gen",
"build/runner",
"ftl",
"pylib/rsbridge",
"qt/bundle/mac",
"qt/bundle/win",
"rslib",
"rslib/i18n",
"rslib/linkchecker",
"rslib/proto",
"rslib/io",
"rslib/linkchecker",
"rslib/process",
"rslib/proto",
"rslib/sync",
"pylib/rsbridge",
"build/configure",
"build/ninja_gen",
"build/runner",
"ftl",
"tools/minilints",
"qt/bundle/win",
"qt/bundle/mac",
]
exclude = ["qt/bundle"]
resolver = "2"
Expand All @@ -35,7 +35,7 @@ git = "https://github.com/ankitects/linkcheck.git"
rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca"

[workspace.dependencies.fsrs]
version = "1.1.4"
version = "1.1.5"
# git = "https://github.com/open-spaced-repetition/fsrs-rs.git"
# rev = "58ca25ed2bc4bb1dc376208bbcaed7f5a501b941"
# path = "../open-spaced-repetition/fsrs-rs"
Expand All @@ -45,8 +45,8 @@ version = "1.1.4"
anki = { path = "rslib" }
anki_i18n = { path = "rslib/i18n" }
anki_io = { path = "rslib/io" }
anki_proto = { path = "rslib/proto" }
anki_process = { path = "rslib/process" }
anki_proto = { path = "rslib/proto" }
anki_proto_gen = { path = "rslib/proto_gen" }
ninja_gen = { "path" = "build/ninja_gen" }

Expand Down Expand Up @@ -74,6 +74,9 @@ criterion = { version = "0.5.1" }
csv = "1.3.0"
data-encoding = "2.6.0"
difflib = "0.4.0"
dirs = "5.0.1"
dunce = "1.0.4"
envy = "0.4.2"
flate2 = "1.0.30"
fluent = "0.16.1"
fluent-bundle = "0.15.3"
Expand Down Expand Up @@ -145,9 +148,6 @@ wiremock = "0.5.22"
xz2 = "0.1.7"
zip = { version = "0.6.6", default-features = false, features = ["deflate", "time"] }
zstd = { version = "0.13.2", features = ["zstdmt"] }
envy = "0.4.2"
dirs = "5.0.1"
dunce = "1.0.4"

# Apply mild optimizations to our dependencies in dev mode, which among other things
# improves sha2 performance by about 21x. Opt 1 chosen due to
Expand Down
2 changes: 1 addition & 1 deletion cargo/licenses.json
Original file line number Diff line number Diff line change
Expand Up @@ -1252,7 +1252,7 @@
},
{
"name": "fsrs",
"version": "1.1.4",
"version": "1.1.5",
"authors": "Open Spaced Repetition",
"repository": "https://github.com/open-spaced-repetition/fsrs-rs",
"license": "BSD-3-Clause",
Expand Down
4 changes: 2 additions & 2 deletions ftl/core/deck-config.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ deck-config-new-gather-priority-random-notes = Random notes
deck-config-new-gather-priority-random-cards = Random cards
deck-config-new-card-sort-order = New card sort order
deck-config-new-card-sort-order-tooltip-2 =
`Card type`: Displays cards in order of card type number. If you have sibling burying
`Card type, then order gathered`: Displays cards in order of card type number. If you have sibling burying
disabled, this will ensure all front→back cards are seen before any back→front cards.
This is useful to have all cards of the same note shown in the same session, but not
too close to one another.
Expand All @@ -180,7 +180,7 @@ deck-config-new-card-sort-order-tooltip-2 =
deck-config-sort-order-card-template-then-random = Card type, then random
deck-config-sort-order-random-note-then-template = Random note, then card type
deck-config-sort-order-random = Random
deck-config-sort-order-template-then-gather = Card type
deck-config-sort-order-template-then-gather = Card type, then order gathered
deck-config-sort-order-gather = Order gathered
deck-config-new-review-priority = New/review order
deck-config-new-review-priority-tooltip = When to show new cards in relation to review cards.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"caniuse-lite": "^1.0.30001431",
"cross-env": "^7.0.2",
"diff": "^5.0.0",
"dprint": "=0.35.3",
"dprint": "^0.47.2",
"esbuild": "^0.18.10",
"esbuild-sass-plugin": "^2",
"esbuild-svelte": "^0.7.4",
Expand Down
6 changes: 3 additions & 3 deletions pylib/anki/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ def set_browser_note_columns(self, columns: list[str]) -> None:
# Config
##########################################################################

def get_config(self, key: str, default: Any = None) -> Any:
def get_config(self, key: str, default: Any | None = None) -> Any:
try:
return self.conf.get_immutable(key)
except KeyError:
Expand Down Expand Up @@ -941,7 +941,7 @@ def set_config_string(
return self._backend.set_config_string(key=key, value=value, undoable=undoable)

def get_aux_notetype_config(
self, id: NotetypeId, key: str, default: Any = None
self, id: NotetypeId, key: str, default: Any | None = None
) -> Any:
key = self._backend.get_aux_notetype_config_key(id=id, key=key)
return self.get_config(key, default=default)
Expand All @@ -953,7 +953,7 @@ def set_aux_notetype_config(
return self.set_config(key, value, undoable=undoable)

def get_aux_template_config(
self, id: NotetypeId, card_ordinal: int, key: str, default: Any = None
self, id: NotetypeId, card_ordinal: int, key: str, default: Any | None = None
) -> Any:
key = self._backend.get_aux_template_config_key(
notetype_id=id, card_ordinal=card_ordinal, key=key
Expand Down
2 changes: 1 addition & 1 deletion pylib/anki/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __getitem__(self, key: str) -> Any:
def __setitem__(self, key: str, value: Any) -> None:
self.set(key, value)

def get(self, key: str, default: Any = None) -> Any:
def get(self, key: str, default: Any | None = None) -> Any:
try:
return self[key]
except KeyError:
Expand Down
2 changes: 1 addition & 1 deletion pylib/anki/decks.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, col: anki.collection.Collection) -> None:
self.col = col.weakref()
self.decks = DecksDictProxy(col)

def save(self, deck_or_config: DeckDict | DeckConfigDict = None) -> None:
def save(self, deck_or_config: DeckDict | DeckConfigDict | None = None) -> None:
"Can be called with either a deck or a deck configuration."
if not deck_or_config:
print("col.decks.save() should be passed the changed deck")
Expand Down
2 changes: 1 addition & 1 deletion pylib/anki/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def post(self, url: str, data: bytes, headers: dict[str, str] | None) -> Respons
verify=self.verify,
) # pytype: disable=wrong-arg-types

def get(self, url: str, headers: dict[str, str] = None) -> Response:
def get(self, url: str, headers: dict[str, str] | None = None) -> Response:
if headers is None:
headers = {}
headers["User-Agent"] = self._agent_name()
Expand Down
2 changes: 1 addition & 1 deletion pylib/anki/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ def update(
self._mutate_after_write(notetype)

# @deprecated(replaced_by=update_dict)
def save(self, notetype: NotetypeDict = None, **legacy_kwargs: bool) -> None:
def save(self, notetype: NotetypeDict | None = None, **legacy_kwargs: bool) -> None:
"Save changes made to provided note type."
if not notetype:
print_deprecation_warning(
Expand Down
2 changes: 1 addition & 1 deletion pylib/anki/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(
card: anki.cards.Card,
note: anki.notes.Note,
browser: bool = False,
notetype: NotetypeDict = None,
notetype: NotetypeDict | None = None,
template: dict | None = None,
fill_empty: bool = False,
) -> None:
Expand Down
4 changes: 3 additions & 1 deletion qt/aqt/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ def allAddonConflicts(self) -> dict[str, list[str]]:
all_conflicts[other_dir].append(addon.dir_name)
return all_conflicts

def _disableConflicting(self, module: str, conflicts: list[str] = None) -> set[str]:
def _disableConflicting(
self, module: str, conflicts: list[str] | None = None
) -> set[str]:
if not self.isEnabled(module):
# disabled add-ons should not trigger conflict handling
return set()
Expand Down
2 changes: 1 addition & 1 deletion qt/aqt/browser/sidebar/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
name: str,
icon: str | ColoredIcon,
search_node: SearchNode | None = None,
on_expanded: Callable[[bool], None] = None,
on_expanded: Callable[[bool], None] | None = None,
expanded: bool = False,
item_type: SidebarItemType = SidebarItemType.CUSTOM,
id: int = 0,
Expand Down
2 changes: 1 addition & 1 deletion qt/aqt/browser/sidebar/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def refresh_if_needed(self) -> None:
self.refresh()
self._refresh_needed = False

def refresh(self, new_current: SidebarItem = None) -> None:
def refresh(self, new_current: SidebarItem | None = None) -> None:
"Refresh list. No-op if sidebar is not visible."
if not self.isVisible():
return
Expand Down
4 changes: 3 additions & 1 deletion qt/aqt/browser/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ def _scroll_to_column(self, column: int) -> None:
self._view.verticalScrollBar().setValue(vertical)

def _move_current(
self, direction: QAbstractItemView.CursorAction, index: QModelIndex = None
self,
direction: QAbstractItemView.CursorAction,
index: QModelIndex | None = None,
) -> None:
if not self.has_current():
return
Expand Down
4 changes: 2 additions & 2 deletions qt/aqt/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ def addButton(
func: Callable[[Editor], None],
tip: str = "",
label: str = "",
id: str = None,
id: str | None = None,
toggleable: bool = False,
keys: str = None,
keys: str | None = None,
disables: bool = True,
rightside: bool = True,
) -> str:
Expand Down
2 changes: 1 addition & 1 deletion qt/aqt/import_export/exporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def get_out_path(self) -> str | None:
return path

def options(self, out_path: str) -> ExportOptions:
limit: ExportLimit = None
limit: ExportLimit | None = None
if self.nids:
limit = NoteIdsLimit(self.nids)
elif current_deck_id := self.current_deck_id():
Expand Down
2 changes: 1 addition & 1 deletion qt/aqt/importing.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def setupOptions(self) -> None:
)
self.deck = aqt.deckchooser.DeckChooser(self.mw, self.frm.deckArea, label=False)

def modelChanged(self, unused: Any = None) -> None:
def modelChanged(self, unused: Any | None = None) -> None:
self.importer.model = self.mw.col.models.current()
self.importer.initMapping()
self.showMapping()
Expand Down
4 changes: 2 additions & 2 deletions qt/aqt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,8 @@ def reset(self, unused_arg: bool = False) -> None:
def requireReset(
self,
modal: bool = False,
reason: Any = None,
context: Any = None,
reason: Any | None = None,
context: Any | None = None,
) -> None:
traceback.print_stack(file=sys.stdout)
print("requireReset() is obsolete; please use CollectionOp()")
Expand Down
1 change: 1 addition & 0 deletions qt/aqt/mediasrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ def handle_on_main() -> None:
"set_wants_abort",
"evaluate_weights",
"get_optimal_retention_parameters",
"simulate_fsrs_review",
]


Expand Down
21 changes: 14 additions & 7 deletions qt/aqt/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ def load(self, name: str) -> bool:
if name == "_global":
raise Exception("_global is not a valid name")
data = self.db.scalar(
"select cast(data as blob) from profiles where name = ?", name
"select cast(data as blob) from profiles where name = ? collate nocase",
name,
)
self.name = name
try:
Expand All @@ -232,22 +233,26 @@ def load(self, name: str) -> bool:
return True

def save(self) -> None:
sql = "update profiles set data = ? where name = ?"
sql = "update profiles set data = ? where name = ? collate nocase"
self.db.execute(sql, self._pickle(self.profile), self.name)
self.db.execute(sql, self._pickle(self.meta), "_global")
self.db.commit()

def create(self, name: str) -> None:
prof = profileConf.copy()
if self.db.scalar("select 1 from profiles where name = ? collate nocase", name):
return
self.db.execute(
"insert or ignore into profiles values (?, ?)", name, self._pickle(prof)
"insert or ignore into profiles values (?, ?)",
name,
self._pickle(prof),
)
self.db.commit()

def remove(self, name: str) -> None:
path = self.profileFolder(create=False)
send_to_trash(Path(path))
self.db.execute("delete from profiles where name = ?", name)
self.db.execute("delete from profiles where name = ? collate nocase", name)
self.db.commit()

def trashCollection(self) -> None:
Expand Down Expand Up @@ -277,7 +282,9 @@ def rename(self, name: str) -> None:
return

# update name
self.db.execute("update profiles set name = ? where name = ?", name, oldName)
self.db.execute(
"update profiles set name = ? where name = ? collate nocase", name, oldName
)
# rename folder
try:
os.rename(oldFolder, newFolder)
Expand Down Expand Up @@ -403,7 +410,7 @@ def recover() -> None:
self.db.execute(
"""
create table if not exists profiles
(name text primary key, data blob not null);"""
(name text primary key collate nocase, data blob not null);"""
)
data = self.db.scalar(
"select cast(data as blob) from profiles where name = '_global'"
Expand Down Expand Up @@ -485,7 +492,7 @@ def _onLangSelected(self) -> None:

def setLang(self, code: str) -> None:
self.meta["defaultLang"] = code
sql = "update profiles set data = ? where name = ?"
sql = "update profiles set data = ? where name = ? collate nocase"
self.db.execute(sql, self._pickle(self.meta), "_global")
self.db.commit()
anki.lang.set_lang(code)
Expand Down
Loading

0 comments on commit f7fb0e4

Please sign in to comment.