refactor(constants): derive multi-choice lists from Literal aliases#686
Merged
JWCook merged 2 commits intoFeb 28, 2026
Merged
Conversation
Contributor
Author
|
Pushed a small formatting-only follow-up in b6111c3 to fix the CI analyze job (ruff-format adjusted one blank line in constants.py).\n\nLocal validation after that commit:\n- uv tool run ruff check pyinaturalist/constants.py test/docs/test_signatures.py\n- uv run pytest -q test/docs/test_signatures.py (16 passed) |
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.
Summary
Use
typing.get_args()to derive runtime multi-choice constants from existingLiteralaliases, so each choice set is declared once and reused for both typing and validation.Closes #685
Changes
_literal_values()helper inpyinaturalist/constants.pyLiteralaliases above runtime constantsINBOXES,COMMUNITY_ID_STATUSES,CONSERVATION_STATUSES,GEOPRIVACY_LEVELS,HISTOGRAM_DATE_FIELDS,HISTOGRAM_INTERVALS,ID_CATEGORIES,ORDER_DIRECTIONS,PROJECT_TYPES,QUALITY_GRADES,SEARCH_PROPERTIES,SOURCES, andCC_LICENSESMULTIPLE_CHOICE_PARAMS['iconic_taxa']to use a sharedICONIC_TAXON_CHOICESlistLiteral[*list]in this areaValidation
uv tool run ruff check pyinaturalist/constants.py test/docs/test_signatures.pyuv run pytest -q test/docs/test_signatures.py