Skip to content

Conversation

@m-akinc
Copy link
Contributor

@m-akinc m-akinc commented Sep 8, 2021

When we try to add suppressions in empty files, it results in index out of range errors. Really, it's a result of a linter error being reported on a non-existent line (i.e. line 1 of empty file). The _add_noqa_to_line function takes in the array of lines and modifies the contents, so the easiest way to avoid this problem is to populate the lines array with a single blank line when the file is empty. Also, the multiline checker has a similar problem, but we can avoid that easily by checking that the error.line is within range before calling multiline_checker.in_multiline_string.

@mshafer-NI
Copy link
Collaborator

@m-akinc
Copy link
Contributor Author

m-akinc commented Sep 8, 2021

Can we add these cases to the system tests?
https://github.com/ni/python-styleguide/tree/main/tests/test_cli/acknowledge_existing_errors_test_cases__snapshots

Added test for empty file

@m-akinc m-akinc closed this Sep 8, 2021
@m-akinc m-akinc reopened this Sep 8, 2021
Copy link
Collaborator

@mshafer-NI mshafer-NI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - thanks for adding the test

@mshafer-NI mshafer-NI merged commit 0ff7698 into ni:main Sep 9, 2021
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

Successfully merging this pull request may close these issues.

3 participants