mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:12:22 +00:00
Avoid PTH206
with maxsplit
(#6283)
## Summary Avoid suggesting `Path.parts` when a `maxsplit` is specified, since these behavior differently. ## Test Plan `cargo test`
This commit is contained in:
parent
23b8fc4366
commit
556abf4bd3
2 changed files with 8 additions and 1 deletions
|
@ -18,3 +18,5 @@ file_name.split(os.sep)
|
||||||
|
|
||||||
# OK
|
# OK
|
||||||
"foo/bar/".split("/")
|
"foo/bar/".split("/")
|
||||||
|
"foo/bar/".split(os.sep, 1)
|
||||||
|
"foo/bar/".split(1, sep=os.sep)
|
||||||
|
|
|
@ -60,7 +60,12 @@ pub(crate) fn os_sep_split(checker: &mut Checker, call: &ast::ExprCall) {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Match `.split(os.sep)` or `.split(sep=os.sep)`
|
// Match `.split(os.sep)` or `.split(sep=os.sep)`, but avoid cases in which a `maxsplit` is
|
||||||
|
// specified.
|
||||||
|
if call.arguments.len() != 1 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let Some(sep) = call.arguments.find_argument("sep", 0) else {
|
let Some(sep) = call.arguments.find_argument("sep", 0) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue