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

Normalize line breaks visitor #101

Merged
merged 8 commits into from
Dec 16, 2024

Conversation

nielsdebruin
Copy link
Contributor

@nielsdebruin nielsdebruin commented Dec 12, 2024

What's changed?

A draft version of Normalize Line Breaks Visitor has been added, The goal of this draft PR is to gain some further suggestions for its final implementation.

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 self-assigned this Dec 12, 2024
@nielsdebruin nielsdebruin added the enhancement New feature or request label Dec 12, 2024
@nielsdebruin nielsdebruin changed the title WIP: Draft of normalize line breaks visitor Normalize line breaks visitor Dec 13, 2024
@nielsdebruin nielsdebruin marked this pull request as ready for review December 13, 2024 09:24
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.

Apart from that small comment and the merging from main to get the parser fix, I think this looks good.

@@ -2,6 +2,7 @@

from .blank_lines import BlankLinesVisitor
from .normalize_format import NormalizeFormatVisitor
from .normalize_line_breaks_visitor import NormalizeLineBreaksVisitor
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like we still need to call the visitor.

self._stop = False
self._style = style

def visit_space(self, space: Optional[Space], loc: Optional[Union[PySpace.Location, Space.Location]],
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here we will need an override for visit_marker, because the base visitor class doesn't know about specific markers and thus won't visit the Space of TrailingComma.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be fixed

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 a test case with a trailing comma for this visitor? I don't see the visit_marker override anywhere.

@nielsdebruin nielsdebruin merged commit bc667d6 into main Dec 16, 2024
1 of 2 checks passed
@nielsdebruin nielsdebruin deleted the autoformat/normalize-linebreaks-visitor branch December 16, 2024 11:29
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.

2 participants