fix(safaa): handle non-list iterables in _ensure_list_of_strings#48
Open
Valyrian-Code wants to merge 1 commit into
Open
fix(safaa): handle non-list iterables in _ensure_list_of_strings#48Valyrian-Code wants to merge 1 commit into
Valyrian-Code wants to merge 1 commit into
Conversation
_ensure_list_of_strings called data.to_list() when the input was not a list. to_list is a pandas Series method, so tuples, generators, sets and other iterables raised AttributeError despite the docstring stating the parameter accepts an "iterable". Replace with list(data), which works uniformly for lists, tuples, generators, pandas Series, numpy arrays, and any other iterable. Also introduce a pytest-based test suite (the repo previously had none), add pytest to the dev dependencies, and cover the regression path along with baseline tests for predict() and declutter() so future refactors have a safety net. Signed-off-by: RAJVEER42 <irajveer.bishnoi2310@gmail.com>
This was referenced May 23, 2026
Author
|
Hi @GMishx & @Kaushl2208 Hi! I opened a small PR with bug fixes and regression tests. I’d appreciate a review whenever you have time thanks for maintaining the project! |
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.

Description
_ensure_list_of_stringswas documented to accept any iterable but only worked forlistandpandas.Series. Tuples, generators, sets, and other iterables raised:because
to_list()is a pandas-specific method.This PR replaces
data.to_list()withlist(data), allowing all standard iterables to be handled consistently without changing behavior for existing callers.Changes
[Safaa.py#L147](https://github.com/fossology/safaa/blob/main/Safaa/src/safaa/Safaa.py?utm_source=chatgpt.com#L147)
Replace:
with:
[pyproject.toml](https://github.com/fossology/safaa/blob/main/pyproject.toml?utm_source=chatgpt.com)
Add
pytestto dev dependenciestests/__init__.py,tests/test_safaa.pyAdd initial pytest-based test suite, including:
TestEnsureListOfStringsTestPredictTestDeclutterThe new tests cover lists, tuples, generators, pandas Series, numpy arrays, mixed types, empty inputs, and regression cases for the original bug.
How to test
All tests pass.
Regression check
Previously failing inputs now work correctly:
This closes #47.