Open seamuswn opened 22 hours ago
At the moment ast-grep does not support file level suppression. You can try using exclude to suppress warning.
Another issue here is that comment suppression seems to be unable suppress module, the root AST. I will investigate it later.
The issue here is how ast-grep handle ignore comment
# ast-grep-ignore
'this only ignores the next line'
'this only ignores the current line' # ast-grep-ignore
So the leading comment does not ignore the module
ast
Please read the FAQ for the bug you encountered.
⏯ Playground Link
https://ast-grep.github.io/playground.html#eyJtb2RlIjoiQ29uZmlnIiwibGFuZyI6InB5dGhvbiIsInF1ZXJ5IjoiY29uc29sZS5sb2coJE1BVENIKSIsInJld3JpdGUiOiJsb2dnZXIubG9nKCRNQVRDSCkiLCJzdHJpY3RuZXNzIjoic21hcnQiLCJzZWxlY3RvciI6IiIsImNvbmZpZyI6Ii0tLVxuaWQ6IGVtcHR5X2luaXRfZmlsZXNcbmxhbmd1YWdlOiBQeXRob25cbnNldmVyaXR5OiBlcnJvclxubWVzc2FnZTogfFxuICBgX19pbml0X18ucHlgIGZpbGVzIHNob3VsZCBiZSBlbXB0eSBhc2lkZSBmcm9tIGltcG9ydHNcblxucnVsZTpcbiAga2luZDogbW9kdWxlXG4gIGhhczpcbiAgICBub3Q6XG4gICAgICBhbnk6XG4gICAgICAgIC0ga2luZDogaW1wb3J0X2Zyb21fc3RhdGVtZW50XG4gICAgICAgIC0ga2luZDogaW1wb3J0X3N0YXRlbWVudFxuXG5maWxlczpcbiAgLSAnKiovX19pbml0X18ucHknXG4iLCJzb3VyY2UiOiIjIGFzdC1ncmVwLWlnbm9yZTogZW1wdHlfaW5pdF9maWxlc1xuZnJvbSBmb28gaW1wb3J0IGJhclxuaW1wb3J0IGZvb1xuXG5mb28gPSBiYXIifQ==
💻 Code
🙁 Actual behavior
With rule above, and
# ast-grep-ignore: empty_init_files
as first line in the module, ast-grep complains about/my/path/__init__.py:1:1: error[empty_init_files]:
init.pyfiles should be empty aside from imports
but also/my/path/__init__.py:1:1: help[unused-suppression]: Unused '@ast-grep-ignore' directive.
🙂 Expected behavior
Placing module suppression on very first line should result in this rule being ignored and ast-grep scan passing.
Additional information about the issue
No response