Features for refactoring automatically offending code (pylint autofix) #7438
Labels
Discussion 🤔
High effort 🏋
Difficult solution or problem to solve
Needs design proposal 🔒
This is a huge feature, some discussion should happen before a PR is proposed
Needs investigation 🔬
A bug or crash where it's not immediately obvious what is happenning
Current problem
Recently, a paper could automatically refactor non-idiomatic Python code with nine Python idioms: List/set/dict-comprehension, chain-comparison, truth-value-test, loop-else, star-in-function-call, assign-multiple-targets, for-multiple-targets. And they pulled some requests to GitHub projects and many project members like the feature. And some developers proposed issues for Pylint project such as #5800, a developer said “Would it be an idea for Pylint to output the suggested refactor to the user” in Pylint.
Therefore, I would like to try to integrate the functionality into Pylint, what do you think of the idea?
For example, for the list-comprehension, the paper could refactor the code from GitHub project,
into
.
For another example, for the for-multiple-targets, the paper could refactor the code from GitHub project:
into
Desired solution
If I could do this, currently I want to refer to the source code of Refactoring checker. Maybe I want to create a new class for each python idiom and register them in https://github.com/PyCQA/pylint/blob/main/pylint/checkers/refactoring/__init__.py. And then, I maybe refer to https://github.com/PyCQA/pylint/blob/055c1920140ebf36501d30307d5ab86965ae185f/pylint/checkers/refactoring/refactoring_checker.py to implement the details of code refactoring.
For example,
How about the method or some suggestions?
Additional context
https://arxiv.org/abs/2207.05613
The text was updated successfully, but these errors were encountered: