You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 1, 2019. It is now read-only.
I'm using this bug to get familiar with the internals of prettier and this plugin. My naive approach to getting this done is by adding a new prettier printer option to specify a trailing comment prefix here. Something like options.printer.trailingCommentPrefix, with a default of a single space, but plugin-python would provide a two-space string.
This change yields the following output for yarn prettier tests/python_comments/comments.py:
$ prettier --plugin=. --parser=python tests/python_comments/comments.py
- if a: # a+ if a: # a
# b
c
# c
d
# e
call()
# a
However, this seems like a pretty granular configuration option to me, compared to the existing printer options. And I doubt you all want to go down the path where plugin-python is doing all the comment printer handling with the willPrintOwnComments option. Interested in hearing alternative solutions.
@j-f1 Not sure if I'm understanding your suggestion, but here's what happens when I change plugin-python's printComment to return group(concat([line, comment.value])):
$ prettier --plugin=. --parser=python tests/python_comments/comments.py
if a: # a
# b
c
# c
d
# e
call()
# a
As you can see, it adds an extra space even to comments that aren't inline.
Note: I also had to modify the final case in prettier's printTrailingComment from " " + contents to concat([" ", contents]), otherwise it would print:
$ prettier --plugin=. --parser=python tests/python_comments/comments.py
if a: [object Object]
# b
c
# c
d
# e
call()
# a
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
See PEP-8: https://www.python.org/dev/peps/pep-0008/#comments
The text was updated successfully, but these errors were encountered: