-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: flake8-use-pathlib PTH100-124 (#2090)
- Loading branch information
Showing
22 changed files
with
1,748 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Rodolphe Pelloux-Prayer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import os.path | ||
|
||
p = "/foo" | ||
|
||
a = os.path.abspath(p) | ||
aa = os.chmod(p) | ||
aaa = os.mkdir(p) | ||
os.makedirs(p) | ||
os.rename(p) | ||
os.replace(p) | ||
os.rmdir(p) | ||
os.remove(p) | ||
os.unlink(p) | ||
os.getcwd(p) | ||
b = os.path.exists(p) | ||
bb = os.path.expanduser(p) | ||
bbb = os.path.isdir(p) | ||
bbbb = os.path.isfile(p) | ||
bbbbb = os.path.islink(p) | ||
os.readlink(p) | ||
os.stat(p) | ||
os.path.isabs(p) | ||
os.path.join(p) | ||
os.path.basename(p) | ||
os.path.dirname(p) | ||
os.path.samefile(p) | ||
os.path.splitext(p) | ||
with open(p) as fp: | ||
fp.read() | ||
open(p).close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os as foo | ||
import os.path as foo_p | ||
|
||
p = "/foo" | ||
|
||
a = foo_p.abspath(p) | ||
aa = foo.chmod(p) | ||
aaa = foo.mkdir(p) | ||
foo.makedirs(p) | ||
foo.rename(p) | ||
foo.replace(p) | ||
foo.rmdir(p) | ||
foo.remove(p) | ||
foo.unlink(p) | ||
foo.getcwd(p) | ||
b = foo_p.exists(p) | ||
bb = foo_p.expanduser(p) | ||
bbb = foo_p.isdir(p) | ||
bbbb = foo_p.isfile(p) | ||
bbbbb = foo_p.islink(p) | ||
foo.readlink(p) | ||
foo.stat(p) | ||
foo_p.isabs(p) | ||
foo_p.join(p) | ||
foo_p.basename(p) | ||
foo_p.dirname(p) | ||
foo_p.samefile(p) | ||
foo_p.splitext(p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from os import chmod, mkdir, makedirs, rename, replace, rmdir | ||
from os import remove, unlink, getcwd, readlink, stat | ||
from os.path import abspath, exists, expanduser, isdir, isfile, islink | ||
from os.path import isabs, join, basename, dirname, samefile, splitext | ||
|
||
p = "/foo" | ||
|
||
a = abspath(p) | ||
aa = chmod(p) | ||
aaa = mkdir(p) | ||
makedirs(p) | ||
rename(p) | ||
replace(p) | ||
rmdir(p) | ||
remove(p) | ||
unlink(p) | ||
getcwd(p) | ||
b = exists(p) | ||
bb = expanduser(p) | ||
bbb = isdir(p) | ||
bbbb = isfile(p) | ||
bbbbb = islink(p) | ||
readlink(p) | ||
stat(p) | ||
isabs(p) | ||
join(p) | ||
basename(p) | ||
dirname(p) | ||
samefile(p) | ||
splitext(p) | ||
with open(p) as fp: | ||
fp.read() | ||
open(p).close() |
35 changes: 35 additions & 0 deletions
35
resources/test/fixtures/flake8_use_pathlib/import_from_as.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from os import chmod as xchmod, mkdir as xmkdir | ||
from os import makedirs as xmakedirs, rename as xrename, replace as xreplace | ||
from os import rmdir as xrmdir, remove as xremove, unlink as xunlink | ||
from os import getcwd as xgetcwd, readlink as xreadlink, stat as xstat | ||
from os.path import abspath as xabspath, exists as xexists | ||
from os.path import expanduser as xexpanduser, isdir as xisdir | ||
from os.path import isfile as xisfile, islink as xislink, isabs as xisabs | ||
from os.path import join as xjoin, basename as xbasename, dirname as xdirname | ||
from os.path import samefile as xsamefile, splitext as xsplitext | ||
|
||
p = "/foo" | ||
|
||
a = xabspath(p) | ||
aa = xchmod(p) | ||
aaa = xmkdir(p) | ||
xmakedirs(p) | ||
xrename(p) | ||
xreplace(p) | ||
xrmdir(p) | ||
xremove(p) | ||
xunlink(p) | ||
xgetcwd(p) | ||
b = xexists(p) | ||
bb = xexpanduser(p) | ||
bbb = xisdir(p) | ||
bbbb = xisfile(p) | ||
bbbbb = xislink(p) | ||
xreadlink(p) | ||
xstat(p) | ||
xisabs(p) | ||
xjoin(p) | ||
xbasename(p) | ||
xdirname(p) | ||
xsamefile(p) | ||
xsplitext(p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import py | ||
|
||
p = py.path.local("../foo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from py.path import local as path | ||
|
||
p = path("/foo") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.