Repository navigation
fix(filters): allow FastTextClassifierFilter without keep_labels or remove_labels - #563
Merged
davanstrien merged 3 commits intoNov 4, 2026
Merged
Conversation
Concatenating the two label lists raised TypeError when keep_labels was a tuple of tuples, which worked before this change. Unpacking handles None, lists and tuples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
The
FastTextClassifierFilterdocstring says that if you supply neitherkeep_labelsnorremove_labels, the block annotates each document with the label scores. In that mode the first document raises aTypeErrorwhen the model loads:The label check in the
modelproperty is written asself.keep_labels or [] + self.remove_labels or []. Python parses this asself.keep_labels or ([] + self.remove_labels) or [], so when both areNoneit evaluates[] + None.This change adds parentheses so both lists default to
[]before they are joined. The behavior withkeep_labelsorremove_labelsset does not change.Tests
TestFastTextClassifierFilter.test_annotates_without_keep_or_remove_labels: runs the filter with neither label list and checks that the document is kept and the scores land in its metadata. It fails onmainwith theTypeErrorabove and passes with this change.TestFastTextClassifierFilter.test_rejects_unknown_label: checks that an unknown label inremove_labelsstill raisesValueError.Both tests replace the fastText model with a small stub, so they need no model download or training.
Fixes #562
Note
Low Risk
Single-expression fix in filter setup plus mocked unit tests; no auth, data, or pipeline behavior change beyond fixing the crash.
Overview
Fixes a TypeError when
FastTextClassifierFilterruns in annotate-only mode (neitherkeep_labelsnorremove_labels). Label validation usedself.keep_labels or [] + self.remove_labels or [], which Python grouped as[] + Nonewhen both were unset; it now iterates over[*(self.keep_labels or []), *(self.remove_labels or [])], so the check is a no-op in that mode and unchanged when label lists are provided.Adds
TestFastTextClassifierFilterwith a stubbed FastText model: metadata annotation without label lists, tuple-of-tupleskeep_labels, andValueErrorfor unknownremove_labels.Reviewed by Cursor Bugbot for commit af6371a. Bugbot is set up for automated code reviews on this repo. Configure here.