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

Extra newlines added before function with fmt skip on decorator #3454

Closed
JelleZijlstra opened this issue Dec 19, 2022 · 2 comments · Fixed by #3470
Closed

Extra newlines added before function with fmt skip on decorator #3454

JelleZijlstra opened this issue Dec 19, 2022 · 2 comments · Fixed by #3470
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. F: fmtskip fmt: skip implementation

Comments

@JelleZijlstra
Copy link
Collaborator

    I've just tested this out with a medium-sized codebase. All as expected apart from this one issue with a comment at the end of a function getting 2 newlines added above it. Removing `@decorator1` stops the comment getting moved, as does removing `# fmt:skip`.

image

https://black.vercel.app/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4ADZAIZdAD2IimZxl1N_WlbvK5V9KEd0suDTtKdXyoIEqib4HPPAOaGeijv-QM5F2CIWMxNomuS8WtfuVtc-CBav7wmp196mwOSJGXUmaRTdIwYr1wf881xD3biQ1s52KZSzb20ApVmRJ9HPRaEOhoVMkb9jDbRHrld5-g2LTBdcrPwjnT90_-ZGPvMAAAAAsri7GeyV3k8AAaIB2gEAAEJ-yuKxxGf7AgAAAAAEWVo=

Originally posted by @jgillard in #3407 (comment)

@JelleZijlstra JelleZijlstra added F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. F: fmtskip fmt: skip implementation C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. labels Dec 19, 2022
@JelleZijlstra
Copy link
Collaborator Author

I tested this out and it happens only if both of the decorators on bar are present and the second one has # fmt: skip.

Copy-pastable sample:

def foo():
    pass
    # Comment on next below

@decorator1
@decorator2  # fmt: skip
def bar():
    pass

@yilei
Copy link
Contributor

yilei commented Dec 19, 2022

This has the same underlying issue as #3438, I'll take a look this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: preview style Issues with the preview and unstable style. Add the name of the responsible feature in the title. F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. F: fmtskip fmt: skip implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants