Skip to content

dedupe() crashes with max() empty when an item reduces to an empty string under the default processor #94

Description

@pramodavansaber

Summary

dedupe() calls extractBests(..., score_cutoff=threshold) per item and then max(matches, ...). When an item is reduced to the empty string by the default processor (utils.full_process), every comparison scores 0, so extractBests returns [] (default threshold 70) and max([]) raises ValueError: max() arg is an empty sequence. The code even warns that a processor-emptied query makes all comparisons score 0, then calls max() unconditionally.

Reproduction

from thefuzz.process import dedupe
dedupe(['###', 'apple', 'apple pie'])
# ValueError: max() iterable argument is empty

(utils.full_process('###') yields ''.)

Expected

dedupe() handles an empty-processed item gracefully (e.g. keeps it as its own cluster), rather than crashing.

Actual

Uncaught ValueError from max([]).

Environment

thefuzz 0.22.1 (master @ 1ba86f3), Python 3.12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions