[flake8-use-pathlib] Catch redundant joins in PTH201 and avoid syntax errors (#15177)
Some checks are pending
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions

## Summary

Resolves #10453, resolves #15165.

## Test Plan

`cargo nextest run` and `cargo insta test`.
This commit is contained in:
InSync 2024-12-30 10:31:35 +07:00 committed by GitHub
parent d3492178e1
commit 901b7dd8f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 437 additions and 66 deletions

View file

@ -1,15 +1,70 @@
from pathlib import Path, PurePath
from pathlib import Path as pth
# match
_ = Path(".")
_ = pth(".")
_ = PurePath(".")
_ = Path("")
Path('', )
Path(
'',
)
Path( # Comment before argument
'',
)
Path(
'', # EOL comment
)
Path(
'' # Comment in the middle of implicitly concatenated string
".",
)
Path(
'' # Comment before comma
,
)
Path(
'',
) / "bare"
Path( # Comment before argument
'',
) / ("parenthesized")
Path(
'', # EOL comment
) / ( ("double parenthesized" ) )
( Path(
'' # Comment in the middle of implicitly concatenated string
".",
) )/ (("parenthesized path call")
# Comment between closing parentheses
)
Path(
'' # Comment before comma
,
) / "multiple" / (
"frag" # Comment
'ment'
)
# no match
_ = Path()
print(".")
Path("file.txt")
Path(".", "folder")
PurePath(".", "folder")
Path()