Skip to content

PLE1310 fails on bytes.strip #15968

@dscorbett

Description

@dscorbett

Description

bad-str-strip-call (PLE1310) in Ruff 0.9.4 flags a bytes.strip call when its argument is a str, but that is a false positive because bytes.strip does not accept a str argument.

$ cat >ple1310.py <<'# EOF'
b"".strip("//")
# EOF

$ python ple1310.py 2>&1 | tail -n 1
TypeError: a bytes-like object is required, not 'str'

$ ruff --isolated check --select PLE1310 ple1310.py --output-format concise
ple1310.py:1:11: PLE1310 String `strip` call contains duplicate characters
Found 1 error.

PLE1310 does not flag a bytes.strip call when its argument is a bytes, which a false negative.

$ echo 'b"".strip(b"//")' | ruff --isolated check --select PLE1310 -
All checks passed!

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