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

Autoformat/spacevisitor #96

Merged
merged 42 commits into from
Dec 10, 2024
Merged

Autoformat/spacevisitor #96

merged 42 commits into from
Dec 10, 2024

Conversation

nielsdebruin
Copy link
Contributor

@nielsdebruin nielsdebruin commented Nov 29, 2024

What's changed?

Added progress on space visitor. Based on

What's your motivation?

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@nielsdebruin nielsdebruin added the enhancement New feature or request label Dec 2, 2024
@nielsdebruin nielsdebruin self-assigned this Dec 2, 2024
@knutwannheden knutwannheden linked an issue Dec 3, 2024 that may be closed by this pull request
27 tasks
Copy link
Contributor

@knutwannheden knutwannheden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Let's merge this and fix any remaining issues in follow-up commits. From what I saw we need some tests for trailing comma syntax and we also need to make sure to always use list_map() rather than list comprehensions when updating the LST model.

rewrite/rewrite/markers.py Show resolved Hide resolved
rewrite/rewrite/markers.py Outdated Show resolved Hide resolved
rewrite/rewrite/python/format/spaces_visitor.py Outdated Show resolved Hide resolved
from rewrite.test import rewrite_run, python, RecipeSpec, from_visitor


def test_spaces_within_dict_declaration():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add one more test for the within.braces style? The visitor implements formatting for this, but I don't see any actual test for it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also believe that the formatting style for within.braces probably should also apply to sets, set comprehensions, and dictionary comprehensions. These cases are probably not covered yet by the formatter. Similarly, the within.brackets should also apply to list comprehensions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more case which we should at least have tests for (didn't check if the visitor already covers it or not) is type hints, so that we can check that witin.brackets correctly formats type hints like Union[str, int].

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions could not be made:

  • rewrite-python-remote/src/main/java/org/openrewrite/python/remote/Extensions.java
    • lines 18-20
    • lines 33-32
  • rewrite-python-remote/src/main/java/org/openrewrite/python/remote/PythonReceiver.java
    • lines 31-34
    • lines 2508-2511
  • rewrite-python-remote/src/main/java/org/openrewrite/python/remote/PythonSender.java
    • lines 29-31
    • lines 1187-1190
  • rewrite-python-remote/src/main/java/org/openrewrite/python/remote/PythonValidator.java
    • lines 26-30
  • rewrite-python/src/main/java/org/openrewrite/python/tree/Py.java
    • lines 375-374
  • rewrite-python/src/test/java/org/openrewrite/python/tree/CollectionTest.java
    • lines 40-40

@nielsdebruin nielsdebruin force-pushed the autoformat/spacevisitor branch from 6b64598 to 41e2bac Compare December 10, 2024 11:29
@knutwannheden knutwannheden merged commit d76520c into main Dec 10, 2024
1 of 2 checks passed
@knutwannheden knutwannheden deleted the autoformat/spacevisitor branch December 10, 2024 14:34
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Python Autoformatter: Spaces
2 participants