Skip to content

[RUF055] False positive for re.split with empty string pattern #23629

@harupy

Description

@harupy

Summary

re.split("", s) is flagged by RUF055 and fixed to s.split(""), but str.split raises ValueError: empty separator for empty separators while re.split succeeds:

import re

s = "abc"
re.split("", s)   # ['', 'a', 'b', 'c', '']
s.split("")        # ValueError: empty separator

Version

f1a9a70

Potential fix

Add a guard to skip if the separator is an empty string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions