[flake8-use-pathlib] autofix and new rules#2348
Closed
sbrugman wants to merge 2 commits intoastral-sh:mainfrom
Closed
[flake8-use-pathlib] autofix and new rules#2348sbrugman wants to merge 2 commits intoastral-sh:mainfrom
flake8-use-pathlib] autofix and new rules#2348sbrugman wants to merge 2 commits intoastral-sh:mainfrom
Conversation
0a47e2c to
9655360
Compare
9655360 to
6d0df09
Compare
6d0df09 to
3a0ad10
Compare
3a0ad10 to
2345acb
Compare
flake8-use-pathlib] autofix and new rules
2345acb to
7325334
Compare
PTH200-204:
- Simplify path constructor `Path(".")` to `Path()`
- Replace `os.path.getsize` with `Path.stat()`
Autofix for:
- PTH200: `Path(".")` to `Path()`
- PTH109: `os.path.getcwd(x)` to `Path(x).cwd()`
Promote `get_member_import_name_alias` from `pylint` to `ast.helpers`
7325334 to
69884b3
Compare
bdc347e to
e8285f8
Compare
5 tasks
Member
|
We should finally be able to support this once #3787 lands. |
Contributor
Author
|
Anyone interested, feel free to pick up where this PR left off (@aqeelat perhaps?). I'd like to work on it, but do not expect it to fit soon. |
I honestly have 0 rust experience and I'm not comfortable taking over. |
This was referenced Jul 17, 2023
charliermarsh
pushed a commit
that referenced
this pull request
Jul 21, 2023
Member
|
@sbrugman - Should we close this out given that it's being ported over in chunks to new PRs? |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See also #2331 and #2090
Kick-off pathlib autofix. The others could mostly be implemented in the same logic, but perhaps good to test with only this small subset to see what occurs in the wild.
PTH201-205:
Simplify path constructorPath(".")toPath()Replaceos.path.getsizewithPath.stat()Using PTH2XX rather than FURBXXX (rules originate fromrefurb) to keep allpathliblogic togetherAutofix for:
PTH201:Path(".")toPath()os.path.getcwd(x)toPath(x).cwd()Nested calls are unwrapped:
Path(os.path.getcwd(x))=>Path(x).cwd()Promote
get_member_import_name_aliasfrompylinttoast.helpersFollow-up work items:
from pathlib import Path) or remove (os/os.path) imports (tracked by Add the possibility to add import and respect the import sorting. #835)os.path.statsis notint(open file descriptors are not supported in the pathlib version). My guess is that this feature is probably not widely used, and people could useos.path.lstatto prevent lints (next to #noqa).Naming convention: rename from pathlib-* to os(-path)-*