-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Detect improvable code with open + pathlib.Path #5289
Copy link
Copy link
Open
Labels
Enhancement ✨Improvement to a componentImprovement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationProposal 📨checker-CodeStyleIssues and PRs that relate to the `CodeStyleChecker`Issues and PRs that relate to the `CodeStyleChecker`
Metadata
Metadata
Assignees
Labels
Enhancement ✨Improvement to a componentImprovement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementationProposal 📨checker-CodeStyleIssues and PRs that relate to the `CodeStyleChecker`Issues and PRs that relate to the `CodeStyleChecker`
Current problem
In the python world. developers tend to use both the old
os.pathbased system andpathlibin parallel. This can lead to some confusion.Recently I've seen some code like this:
Desired solution
Since
opencan consume aPathobject, the above code can be improved toopen(path)orpath.open()Additional context
I'm not 100% sure if this is in the scope of pylint, but calling
strover and over again will lead to a worse performance (even if not too much). Therefore I see such a check as a benefit.I'm also happy to open a PR, if the idea is accepted.