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

Comment alignment when spaces_before_comment is a list #989

Open
01tot10 opened this issue Jan 26, 2022 · 2 comments
Open

Comment alignment when spaces_before_comment is a list #989

01tot10 opened this issue Jan 26, 2022 · 2 comments

Comments

@01tot10
Copy link

01tot10 commented Jan 26, 2022

Hey all!

I've just started using yapf with hopes for making easier the burden of code-cleanup.

I very much like the aesthetics of aligned comments when it comes to blocks of code, but having a list of values in spaces_before_comment kinda creates problems when I have blocks with comments on the side, as well as commented out lines.

I can imagine comments and commented out lines within a block are hard to distinguish programmatically, but is there something in yapf that would allow for not having the problem, where:

from torch.utils.data import DataLoader # this is an important comment
import numpy as np
# import torch
import matplotlib.pyplot as plt
# import sounddevice as sd
# import os
# import torchaudio

gets corrected to:

from torch.utils.data import DataLoader # this is an important comment
import numpy as np
                                        # import torch
import matplotlib.pyplot as plt
                                        # import sounddevice as sd
                                        # import os
                                        # import torchaudio

Thank you in advance!

@lizawang
Copy link

Hi, check out my pull request at #1022, a knob added to choose not to align newline comments with inline comments.

@bwendling
Copy link
Member

Hi @lizawang. I'll take a look at it soon. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants