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

Using noqa with multiline strings #317

Open
tacerus opened this issue Jan 5, 2024 · 1 comment
Open

Using noqa with multiline strings #317

tacerus opened this issue Jan 5, 2024 · 1 comment
Labels
Type: Enhancement New feature or request

Comments

@tacerus
Copy link

tacerus commented Jan 5, 2024

Is your feature request related to a problem? Please describe.

Taking the following pillar as an example:

ssh_known_hosts:
    - >-
        github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9

Here, it seems currently not possible to use noqa overrides. Since multiline strings are interpreted as literals, adding a # noqa: 204 at the end would make the YAML parser add # noqa: 204 to the end of the value.

Describe the solution you'd like

I think a desirable route would be having noqa supported next to the list marker:

ssh_known_hosts:
    - >-  # noqa 204       <-- here
        github.com ssh-rsa 
...

I am not sure if there is anything in the YAML specification which makes this a bad practice, but it seems to parse fine, and avoids the need for an additional line.

Describe alternatives you've considered

An alternative would be supporting noqa in Jinja comments without spaces, that way it could be kept at the end of the line. However {#- noqa 204 #} makes the line even longer than needed.

Jinja comments with whitespace ({# noqa 204 #}, for example) are already supported, but introduce undesired formatting in the rendered file.

Additional context
n/a

@tacerus tacerus added the Type: Enhancement New feature or request label Jan 5, 2024
@tacerus
Copy link
Author

tacerus commented Jan 5, 2024

I proposed a patch here:

#318

It is not completely perfect, it would be nice if the noqa would apply to all lines inside the multiline string, not just the first line.
Feedback welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant