Skip to content

NRT-707: Rename AnKingMCAT note type to AnKing MCAT#39

Merged
RisingOrange merged 16 commits into
masterfrom
mcat-notetype-rename
Apr 22, 2026
Merged

NRT-707: Rename AnKingMCAT note type to AnKing MCAT#39
RisingOrange merged 16 commits into
masterfrom
mcat-notetype-rename

Conversation

@RisingOrange
Copy link
Copy Markdown
Collaborator

@RisingOrange RisingOrange commented Apr 21, 2026

Related issue

NRT-707

Summary

  • Rename bundled AnKingMCAT note type to AnKing MCAT, and introduce a notetype_renames module 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.
  • Update note type discovery in config_window.py, extra_notetype_versions.py, and notetype_setting_definitions.py to recognize both legacy and new names. Extract is_notetype_copy / is_ankihub_notetype_version predicates so the three regex sites share one definition.
  • Add a _notetype_folder_name fallback 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).
  • Prefer canonical > legacy > shortest-name in _most_basic_notetype_version (otherwise the legacy AnKingMCAT wins on length over AnKing MCAT in the config window).
  • Key copy_mids_by_notetype_base_name by canonical name, and rename a legacy main to canonical inside convert_extra_notetypes when the canonical main is missing — so canonical-named copies don't get folded back into the legacy name.
  • Bump flake8 to 6.1.0 (4.0.1 crashes on Python 3.12) and add pytest to pylint's additional_dependencies.
  • Add unit tests for the rename helpers, _notetype_folder_name, _updated_notetype_name collision guard, unrelated-prefix non-match, and the AnKing/AnKing MCAT prefix-collision guard.

How the rename rolls out

  1. This PR merges. Users with AnKingMCAT keep working — the name is recognized as a legacy alias everywhere in the add-on (config window, update detection, extra-copy cleanup).
  2. AnKing-Note-Types PR #252 merges. That renames the source folder and the notetype "name" field. npm build bumps the <!-- version ... --> marker in the templates.
  3. Addon syncs the new templates (via 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).
  4. Edge cases handled inline:
    • AnkiHub-qualified notetypes (... (deck / owner)) are left alone — those renames are owned by the AnkiHub add-on.
    • The config window picks the canonical main as the primary even if a legacy main also exists.
    • The extra-copies cleanup flow keys everything by canonical name; if only a legacy main exists at convert time, it is renamed to canonical first so canonical-named copies fold into canonical.

Test plan

  • pytest tests/ — all tests pass (ran in anki_21_54 pyenv).
  • Manual check in Anki: installing the add-on with an existing AnKingMCAT note type (including AnkiHub-qualified form and -abcde copies) is handled cleanly — no missing/duplicate note type, and config applies to the renamed note type.
  • Manual check: dual main models (both AnKing MCAT and AnKingMCAT present) — config window uses the canonical as the primary.
  • Manual check: canonical-named copies with only a legacy main — copies fold into canonical, and the legacy main is renamed to canonical during the cleanup flow.

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.
- 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.
@RisingOrange RisingOrange changed the title Support MCAT note type rename NRT-707: Rename AnKingMCAT note type to AnKing MCAT Apr 21, 2026
@RisingOrange RisingOrange requested a review from abdnh April 21, 2026 15:13
@RisingOrange RisingOrange merged commit e0a7dc8 into master Apr 22, 2026
1 check passed
@RisingOrange RisingOrange deleted the mcat-notetype-rename branch April 22, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants