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

hatch fmt not placing noqa comments in the correct location #1883

Open
benjunmun opened this issue Jan 10, 2025 · 0 comments
Open

hatch fmt not placing noqa comments in the correct location #1883

benjunmun opened this issue Jan 10, 2025 · 0 comments

Comments

@benjunmun
Copy link

Running hatch fmt can move noqa comments to the wrong line when line-splitting. This caused me additional confusion because a second run of the formatter removed the now-extraneous noqa, and started showing me errors again.

Here is a minimal reproducer, used in a clean hatch new project. The first run of hatch fmt will reformat and return no other errors, but will split the noqa to the wrong line. A second run of hatch fmt will then strip the "invalid" noqa and start showing errors again.

def main():
    some_list = [1, 2, 3]
    another_list = []

    if True:
        if True:
            for item in some_list:
                another_list.append(generate_item( # noqa: PERF401 # Personal preference
                    item=item,
                    stuff=1))

def generate_item(item, stuff):
    return item + stuff

Personally, the biggest usability issue for me was that the first fmt run returned no errors - I usually assume the code would be stable after a run of fmt with no errors.

Hatch version: 1.14.0

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