Skip to content

FURB105 fix should be unsafe when it removes a sep with a possibly incorrect type #20919

Description

@dscorbett

Summary

print’s sep argument must be None or a str, even if it is not used, or it raises an error. The fix for print-empty-string (FURB105) should be marked unsafe when it removes a sep whose type it can’t prove is correct, because that can change the program’s behavior. Example:

$ cat >furb105.py <<'# EOF'
def p(sep):
    print(1, sep=sep)
p(0)
# EOF

$ python furb105.py 2>&1 | tail -n 1
TypeError: sep must be None or a string, not int

$ ruff --isolated check furb105.py --select FURB105 --fix
Found 1 error (1 fixed, 0 remaining).

$ python furb105.py
1

Version

ruff 0.14.0 (beea8cd 2025-10-07)

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions