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

inline comments in function calls removed for SciMLStyle #609

Closed
visr opened this issue Jun 18, 2022 · 2 comments
Closed

inline comments in function calls removed for SciMLStyle #609

visr opened this issue Jun 18, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@visr
Copy link
Contributor

visr commented Jun 18, 2022

t = """
# https://github.com/SciML/SciMLStyle#comments
# In general, comments above a line of code or function are preferred to inline comments.
f(; q) = q
f(
    q = 2  # this comment will be removed
)
"""

format_text(t, style=SciMLStyle()) |> Text

Returns

# https://github.com/SciML/SciMLStyle#comments
# In general, comments above a line of code or function are preferred to inline comments.
f(; q) = q
f(q = 2)

As noted the style guide favors commands above, but I assume the formatter is not supposed to remove them?
#513 and #562 seem similar, but not the same.

For the example of #513 only the last comment gets removed:

f(10 # i got removed!
  *
  10 # me too!
  +
  10)
@domluna domluna added the bug Something isn't working label Jun 18, 2022
@domluna
Copy link
Owner

domluna commented Jun 18, 2022

interesting corner case since SciMLStyle uses YASStyle for a lot of defaults and YASStyle doesn't allow opening/closing parenthesis to be on their own line.

The simplest fix which should still adhere to the style is to put the comment after the closing parenthesis

@visr
Copy link
Contributor Author

visr commented Dec 23, 2024

This seems to be fixed, now the input string is kept as-is.

@visr visr closed this as completed Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants