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:
Charlie Marsh 2023-08-02 14:16:57 -04:00 committed by GitHub
parent 23b8fc4366
commit 556abf4bd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -18,3 +18,5 @@ file_name.split(os.sep)
# OK
"foo/bar/".split("/")
"foo/bar/".split(os.sep, 1)
"foo/bar/".split(1, sep=os.sep)

View file

@ -60,7 +60,12 @@ pub(crate) fn os_sep_split(checker: &mut Checker, call: &ast::ExprCall) {
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 {
return;
};