mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[pylint
] Do not report calls when object type and argument type mismatch, remove custom escape handling logic (PLE1310
) (#15984)
## Summary Resolves #15968. Previously, these would be considered violations: ```python b''.strip('//') ''.lstrip('//', foo = "bar") ``` ...while these are not: ```python b''.strip(b'//') ''.strip('\\b\\x08') ``` Ruff will now not report when the types of the object and that of the argument mismatch, or when there are extra arguments. ## Test Plan `cargo nextest run` and `cargo insta test`.
This commit is contained in:
parent
d4a5772d96
commit
19f3424a1a
4 changed files with 137 additions and 47 deletions
|
@ -64,10 +64,42 @@ u''.strip('http://')
|
|||
u''.lstrip('http://')
|
||||
|
||||
# PLE1310
|
||||
b''.rstrip('http://')
|
||||
b''.rstrip(b'http://')
|
||||
|
||||
# OK
|
||||
''.strip('Hi')
|
||||
|
||||
# OK
|
||||
''.strip()
|
||||
|
||||
|
||||
### https://github.com/astral-sh/ruff/issues/15968
|
||||
|
||||
# Errors: Multiple backslashes
|
||||
''.strip('\\b\\x09')
|
||||
''.strip(r'\b\x09')
|
||||
''.strip('\\\x5C')
|
||||
|
||||
# OK: Different types
|
||||
b"".strip("//")
|
||||
"".strip(b"//")
|
||||
|
||||
# OK: Escapes
|
||||
'\\test'.strip('\\')
|
||||
|
||||
# OK: Extra/missing arguments
|
||||
"".strip("//", foo)
|
||||
b"".lstrip(b"//", foo = "bar")
|
||||
"".rstrip()
|
||||
|
||||
# OK: Not literals
|
||||
foo: str = ""; bar: bytes = b""
|
||||
"".strip(foo)
|
||||
b"".strip(bar)
|
||||
|
||||
# False negative
|
||||
foo.rstrip("//")
|
||||
bar.lstrip(b"//")
|
||||
|
||||
# OK: Not `.[lr]?strip`
|
||||
"".mobius_strip("")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue