Skip to content

refactor(catalog): single-source the object-type code set from OBJ_TYPES#511

Merged
brickbots merged 1 commit into
brickbots:mainfrom
mrosseel:obj-type-centralize
Jul 1, 2026
Merged

refactor(catalog): single-source the object-type code set from OBJ_TYPES#511
brickbots merged 1 commit into
brickbots:mainfrom
mrosseel:obj-type-centralize

Conversation

@mrosseel

@mrosseel mrosseel commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

What

OBJ_TYPES (python/PiFinder/obj_types.py) becomes the single source of truth for the object-type code set, which was hand-duplicated in the filter menu and the docs (and had drifted).

  • Filter menu (ui/menu_structure.py) — the Type filter items are now generated from OBJ_TYPES (drops the hardcoded list of code/label pairs).
  • obj_types.py — reordered to the filter-menu display order (iteration order only; lookups are unaffected) and documented as the canonical source.
  • Drift guard (tests/test_obj_types_docs.py) — fails if anything drifts out of sync with OBJ_TYPES:
    • default_config.json's filter.object_types (the default Type-filter selection) must equal the OBJ_TYPES set, so a newly added type can't be silently off by default;
    • the docs "Object type codes" table must match OBJ_TYPES (no-ops where that table isn't present — it ships in the obslist docs PR — and activates once both land on main).

User-facing change

The Type filter menu adopts the same labels already used on the object-detail screen (they previously disagreed):

Before After
Cluster/Neb Cluster + Neb
P. Nebula Planetary
Double Str Double star
Triple Str Triple star
Unknown Unkn

These msgids already exist and are translated in every locale (they are the detail-screen labels).

Test plan

  • 221 menu/UI tests, catalog/filter/config unit tests, and smoke tests pass; ruff clean.
  • New drift-guard test.

🤖 Generated with Claude Code

The allowed object-type codes were hand-duplicated in the filter menu,
default_config.json and the docs. Make OBJ_TYPES the one source:
- generate the Type filter menu items from OBJ_TYPES (drops the hardcoded list)
- default filter.object_types to list(OBJ_TYPES) instead of a JSON array
- order OBJ_TYPES to the filter-menu display order
- add a drift-guard test (README codes table + default_config)
@mrosseel mrosseel force-pushed the obj-type-centralize branch from 1215e0d to 1699210 Compare June 30, 2026 07:51
@brickbots

Copy link
Copy Markdown
Owner

Thanks @mrosseel great bit of cleanup here!

@brickbots brickbots merged commit 526ab95 into brickbots:main Jul 1, 2026
5 checks passed
hjoungjoo pushed a commit to hjoungjoo/MF_PiFinder that referenced this pull request Jul 2, 2026
…PES (brickbots#511)

The allowed object-type codes were hand-duplicated in the filter menu,
default_config.json and the docs. Make OBJ_TYPES the one source:
- generate the Type filter menu items from OBJ_TYPES (drops the hardcoded list)
- default filter.object_types to list(OBJ_TYPES) instead of a JSON array
- order OBJ_TYPES to the filter-menu display order
- add a drift-guard test (README codes table + default_config)
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