[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:
Sergey Mezentsev 2024-12-12 22:30:17 +03:00 committed by GitHub
parent 71239f248e
commit 68e8496260
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 908 additions and 733 deletions

View file

@ -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")

View file

@ -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")