mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[flake8-use-pathlib
] Extend check for invalid path suffix to include the case "."
(PTH210
) (#14902)
## Summary `PTH210` renamed to `invalid-pathlib-with-suffix` and extended to check for `.with_suffix(".")`. This caused the fix availability to be downgraded to "Sometimes", since there is no fix offered in this case. --------- Co-authored-by: Micha Reiser <micha@reiser.io> Co-authored-by: Dylan <53534755+dylwil3@users.noreply.github.com>
This commit is contained in:
parent
71239f248e
commit
68e8496260
9 changed files with 908 additions and 733 deletions
|
@ -18,31 +18,37 @@ windows_path: pathlib.WindowsPath = pathlib.WindowsPath()
|
|||
|
||||
|
||||
### Errors
|
||||
path.with_suffix(".")
|
||||
path.with_suffix("py")
|
||||
path.with_suffix(r"s")
|
||||
path.with_suffix(u'' "json")
|
||||
path.with_suffix(suffix="js")
|
||||
|
||||
posix_path.with_suffix(".")
|
||||
posix_path.with_suffix("py")
|
||||
posix_path.with_suffix(r"s")
|
||||
posix_path.with_suffix(u'' "json")
|
||||
posix_path.with_suffix(suffix="js")
|
||||
|
||||
pure_path.with_suffix(".")
|
||||
pure_path.with_suffix("py")
|
||||
pure_path.with_suffix(r"s")
|
||||
pure_path.with_suffix(u'' "json")
|
||||
pure_path.with_suffix(suffix="js")
|
||||
|
||||
pure_posix_path.with_suffix(".")
|
||||
pure_posix_path.with_suffix("py")
|
||||
pure_posix_path.with_suffix(r"s")
|
||||
pure_posix_path.with_suffix(u'' "json")
|
||||
pure_posix_path.with_suffix(suffix="js")
|
||||
|
||||
pure_windows_path.with_suffix(".")
|
||||
pure_windows_path.with_suffix("py")
|
||||
pure_windows_path.with_suffix(r"s")
|
||||
pure_windows_path.with_suffix(u'' "json")
|
||||
pure_windows_path.with_suffix(suffix="js")
|
||||
|
||||
windows_path.with_suffix(".")
|
||||
windows_path.with_suffix("py")
|
||||
windows_path.with_suffix(r"s")
|
||||
windows_path.with_suffix(u'' "json")
|
||||
|
|
|
@ -10,6 +10,7 @@ from pathlib import (
|
|||
|
||||
def test_path(p: Path) -> None:
|
||||
## Errors
|
||||
p.with_suffix(".")
|
||||
p.with_suffix("py")
|
||||
p.with_suffix(r"s")
|
||||
p.with_suffix(u'' "json")
|
||||
|
@ -27,6 +28,7 @@ def test_path(p: Path) -> None:
|
|||
|
||||
def test_posix_path(p: PosixPath) -> None:
|
||||
## Errors
|
||||
p.with_suffix(".")
|
||||
p.with_suffix("py")
|
||||
p.with_suffix(r"s")
|
||||
p.with_suffix(u'' "json")
|
||||
|
@ -44,6 +46,7 @@ def test_posix_path(p: PosixPath) -> None:
|
|||
|
||||
def test_pure_path(p: PurePath) -> None:
|
||||
## Errors
|
||||
p.with_suffix(".")
|
||||
p.with_suffix("py")
|
||||
p.with_suffix(r"s")
|
||||
p.with_suffix(u'' "json")
|
||||
|
@ -61,6 +64,7 @@ def test_pure_path(p: PurePath) -> None:
|
|||
|
||||
def test_pure_posix_path(p: PurePosixPath) -> None:
|
||||
## Errors
|
||||
p.with_suffix(".")
|
||||
p.with_suffix("py")
|
||||
p.with_suffix(r"s")
|
||||
p.with_suffix(u'' "json")
|
||||
|
@ -78,6 +82,7 @@ def test_pure_posix_path(p: PurePosixPath) -> None:
|
|||
|
||||
def test_pure_windows_path(p: PureWindowsPath) -> None:
|
||||
## Errors
|
||||
p.with_suffix(".")
|
||||
p.with_suffix("py")
|
||||
p.with_suffix(r"s")
|
||||
p.with_suffix(u'' "json")
|
||||
|
@ -95,6 +100,7 @@ def test_pure_windows_path(p: PureWindowsPath) -> None:
|
|||
|
||||
def test_windows_path(p: WindowsPath) -> None:
|
||||
## Errors
|
||||
p.with_suffix(".")
|
||||
p.with_suffix("py")
|
||||
p.with_suffix(r"s")
|
||||
p.with_suffix(u'' "json")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue