Skip to content

Fix None-safe sort in lab-compare export list_of() #1598#1605

Open
davmlaw wants to merge 1 commit into
masterfrom
issue_1598_lab_compare_sort_none
Open

Fix None-safe sort in lab-compare export list_of() #1598#1605
davmlaw wants to merge 1 commit into
masterfrom
issue_1598_lab_compare_sort_none

Conversation

@davmlaw

@davmlaw davmlaw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What

In classification/views/exports/classification_export_formatter_lab_compare.py, ClassificationLab.list_of() sorts a set of (value, source) tuples directly with sorted(value_set).

Why

When records have partial evidence, a source value can be None. Sorting tuples that differ at a None/str position raises TypeError: '<' not supported between instances of 'str' and 'NoneType', breaking the lab-compare export.

This change adds a sort key that coerces None to an empty string, so sorting is total. Ordering for non-None values is unchanged.

Addresses #1598

🤖 Generated with Claude Code

list_of() sorted a set of (value, source) tuples directly. When some
records have partial evidence, a source value may be None, and Python
raises TypeError comparing str to NoneType during the sort.

Provide a sort key that coerces None to empty string, preserving the
existing ordering for non-None values.
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.

1 participant