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

Add method parameters alignment, fixes to spaces visitor, and extended end2end tests #132

Merged
merged 6 commits into from
Jan 28, 2025

Conversation

nielsdebruin
Copy link
Contributor

What's changed?

This PR adds alignment for method parameters and implements several fixes in the visitor of the space, particularly for imports, and extends the overall test-suite.

What's your motivation?

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

Anyone you would like to review specifically?

@knutwannheden

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 bug Something isn't working enhancement New feature or request labels Jan 27, 2025
@nielsdebruin nielsdebruin self-assigned this Jan 27, 2025
Comment on lines +144 to +146
def_idx = source.index("def")
async_idx = source.find("async")
start_idx = async_idx if async_idx != -1 and async_idx < def_idx else def_idx
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a little bit worried that this could go wrong if there is a decorator or comment including the substring def or async somewhere. It would be safer if we in this FirstArgPrinter would detect when either of these keywords is written and store that in a variable.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am also wondering if this works correctly when for example a decorator is on the same line as the def keyword as in:

@decorator def my_function(a,
        b):
    pass

I suppose this would be easy to test.

Copy link
Contributor Author

@nielsdebruin nielsdebruin Jan 27, 2025

Choose a reason for hiding this comment

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

That is not valid Python (as far as I know)

return self if align_multiline_parameters is self._align_multiline_parameters else replace(self,
_align_multiline_parameters=align_multiline_parameters)

_method_declaration_parameters: MethodDeclarationParameters
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make the same modification to the Java side, where we declare this style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added

@nielsdebruin nielsdebruin merged commit 99e7736 into main Jan 28, 2025
1 check passed
@nielsdebruin nielsdebruin deleted the fixes/mix-fixes branch January 28, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants