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

Some questions about sticky comments #1911

Open
Shivansh-007 opened this issue Mar 18, 2022 · 0 comments
Open

Some questions about sticky comments #1911

Shivansh-007 opened this issue Mar 18, 2022 · 0 comments

Comments

@Shivansh-007
Copy link

psf/black may be adopting isort for formatting its imports, an experimental PR has been opened for this purpose, see psf/black#2941.

On opening this PR, we saw one buggy formatting when the sticky comment was attached to a "group" of imports. Since isort gives sticky comments above imports special meaning, it only assumed that the comment was sticking to the first line of the import where as it was sticking to the full group.

Screenshot from 2022-03-18 22-43-07

Now, isort only maps the comment to the first line of the group i.e. from blib2to3.pytree ... and keeps it alone in the separate group, thus merging the rest into the first party import group.

There isn't a 100% correct solution to this, as not everyone has the same intention when they add comments at the start of the group, it may be for the group as a whole or just the first line of it. But I think the former would be what most cases correspond to. I am not sure how you would go about this or it would be better to leave it as it is.

The problem is currently there are no ways to work this around, so we would need to remove the comment entirely.


Secondly, here it doesn't stick the comment to the first line at all when it is desirable

Screenshot from 2022-03-18 22-40-21


I have no idea about Isort internals right now, this is probably my first time setting it up for a project, so bare with me.

P.S. Great project! Isort is a charm 🖤 🤍

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

1 participant