NRT-707: Rename AnKingMCAT note type to AnKing MCAT#39
Merged
Conversation
flake8 4.0.1 crashes on Python 3.12 due to the importlib_metadata entry_points API change. pytest is added to pylint's additional dependencies so tests that use fixtures lint cleanly.
- Collapse `_updated_notetype_name` branches. - Document why `FULL_NOTETYPE_RENAMES` exists separately from `NOTETYPE_RENAMES`. - Hoist `matching_notetype_names` out of the per-model comprehension in `_note_type_versions`.
Replaces three inline re.match(CONSTANT.format(notetype_base_name=re.escape(x)), y) call sites with named predicates that make the intent explicit at each use.
This was referenced Apr 21, 2026
- Make FULL_NOTETYPE_RENAMES match with an optional copy suffix so AnkiHub-qualified copies like "AnKingMCAT (AnKing-MCAT / AnKingMed)-abcde" rename their deck portion too. - Have _most_basic_notetype_version prefer the canonical name, then any legacy name, before falling back to shortest-name heuristics. Without this, a legacy main (AnKingMCAT, 10 chars) beats the canonical (AnKing MCAT, 11) in the config window. - Rename a legacy main to its canonical name inside convert_extra_notetypes when the canonical main is missing, so canonical copies fold into the canonical name instead of the legacy one.
Locks in the rename-in-place semantics (usn bumped, update_dict called, canonical model returned) and the no-legacy-main fallback.
Conversion may rename a legacy main to its canonical name when the canonical doesn't exist, which is broader than the dialog's "delete extra copies" framing. List the affected renames in the dialog when any will occur so the user can see what will change.
- Return the mutated legacy_model directly instead of re-querying - Hoist all_names_and_ids out of the anking_notetype_names loop - Drop what-not-why comment in convert_extra_notetypes
"AnKing" is a valid base name and a prefix of "AnKing MCAT". The prior match order was iteration order of anking_notetype_names(), so "AnKing MCAT" / "AnKing MCAT-abcde" / AnkiHub-qualified MCAT names could misclassify as "AnKing". Prefer the longest matching name to avoid this.
AnkiHub-qualified notetypes (`... (deck / owner)`) are owned by the AnkiHub add-on — we can't know whether the deck portion is being renamed upstream, so the previous FULL_NOTETYPE_RENAMES machinery could silently corrupt users' notetype names on sync. Drop FULL_NOTETYPE_RENAMES and tighten the rename regex to only match bare or copy-suffixed forms (lookahead `(?=$|-)` instead of `(?=$| |-)`). Detection via notetype_base_name / matching_notetype_names still recognizes AnkiHub-qualified legacy forms via the legacy-name branch, so config window, update detection, and extra-copy cleanup keep working.
abdnh
approved these changes
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
NRT-707
Summary
AnKingMCATnote type toAnKing MCAT, and introduce anotetype_renamesmodule that maps the legacy name to the new. AnkiHub-qualified forms (... (deck / owner)) are still recognized as versions of the canonical notetype, but renaming them is left to the AnkiHub add-on.config_window.py,extra_notetype_versions.py, andnotetype_setting_definitions.pyto recognize both legacy and new names. Extractis_notetype_copy/is_ankihub_notetype_versionpredicates so the three regex sites share one definition._notetype_folder_namefallback so the add-on keeps working if the on-disk folder still uses the legacy name (the folder rename is coordinated in AnKing-Note-Types PR #252)._most_basic_notetype_version(otherwise the legacyAnKingMCATwins on length overAnKing MCATin the config window).copy_mids_by_notetype_base_nameby canonical name, and rename a legacy main to canonical insideconvert_extra_notetypeswhen the canonical main is missing — so canonical-named copies don't get folded back into the legacy name.pytestto pylint'sadditional_dependencies._notetype_folder_name,_updated_notetype_namecollision guard, unrelated-prefix non-match, and the AnKing/AnKing MCAT prefix-collision guard.How the rename rolls out
AnKingMCATkeep working — the name is recognized as a legacy alias everywhere in the add-on (config window, update detection, extra-copy cleanup)."name"field.npm buildbumps the<!-- version ... -->marker in the templates.scripts/get_anking_notetypes.sh). Users see a template update prompt in the AnKing Note Types window, and accepting it renames their notetype at the same time (via_updated_notetype_name, with a collision guard for users who already have both names).... (deck / owner)) are left alone — those renames are owned by the AnkiHub add-on.Test plan
pytest tests/— all tests pass (ran inanki_21_54pyenv).AnKingMCATnote type (including AnkiHub-qualified form and-abcdecopies) is handled cleanly — no missing/duplicate note type, and config applies to the renamed note type.AnKing MCATandAnKingMCATpresent) — config window uses the canonical as the primary.