Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Autoformatter Visitors #112

Closed
7 tasks done
nielsdebruin opened this issue Dec 30, 2024 · 0 comments
Closed
7 tasks done

Python Autoformatter Visitors #112

nielsdebruin opened this issue Dec 30, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@nielsdebruin
Copy link
Contributor

nielsdebruin commented Dec 30, 2024

What problem are you trying to solve?

The autoformatted is an essential part of many open-rewrite recipes. The general structure of the Python autoformatter will follow that of the Java equivalent. Effectively, these consist of a sequence of visitors, each responsible for specific parts of the formatting process. As the Python code is mapped to an LST that is mostly identical to the Java code, we can reuse much of the same logic already implemented in the Java autoformatting visitors. Below is a list of visitors, each of which should be partially implemented for a workable version of the Python autoformatter and their current status.

Visitors Stage 1 (Complete):

  • Blank lines
  • Normalize format
  • Normalize line breaks
  • Normalize tabs or spaces
  • Remove trailing white spaces
  • Spaces
  • Tabs and indents

Important! To achieve a working Python version as swiftly as possible, we designed it to closely resemble the already (working) Java autoformatter. However, the code/structure in the Java autoformatter has built up a decent amount of technical debt and is a good candidate for refactoring. While this approach is likely the quickest way to construct the Python autoformatter, it also transfers technical debt from the Java visitor to the Python autoformatter. Moreover, some of the logic present in the Java autoformatter might not be required/relevant in the Python autoformatter but is also not harmful; hence, after the autoformatter is in working order and adequate test coverage is established, a secondary refactor/review of the code should be performed.

@nielsdebruin nielsdebruin added the enhancement New feature or request label Dec 30, 2024
@nielsdebruin nielsdebruin self-assigned this Dec 30, 2024
@timtebeek timtebeek moved this to Backlog in OpenRewrite Dec 31, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant