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

Add support for pylint #119

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fmts/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions fmts/python.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,14 @@ func init() {
URL: "https://github.com/PyCQA/pydocstyle",
Language: lang,
})

register(&Fmt{
Name: "pylint",
Errorformat: []string{
`%f:%l:%c: %m`,
},
Description: "Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions",
URL: "https://github.com/PyCQA/pylint",
Language: lang,
})
}
44 changes: 44 additions & 0 deletions fmts/testdata/pylint.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
************* Module torch.nn.functional
pytorch/torch/nn/functional.py:874:4: W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py:878:4: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
pytorch/torch/nn/functional.py:878:8: C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
pytorch/torch/nn/functional.py:887:16: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pytorch/torch/nn/functional.py:892:12: C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
pytorch/torch/nn/functional.py:897:20: C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pytorch/torch/nn/functional.py:907:4: W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py:906:0: R0913: Too many arguments (6/5) (too-many-arguments)
pytorch/torch/nn/functional.py:939:11: I1101: Module 'torch._C' has no '_nn' member, but source is unavailable. Consider adding this module to extension-pkg-allow-list if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
pytorch/torch/nn/functional.py:939:11: W0212: Access to a protected member _nn of a client class (protected-access)
pytorch/torch/nn/functional.py:939:11: W0212: Access to a protected member _C of a client class (protected-access)
pytorch/torch/nn/functional.py:943:4: W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py:942:0: R0913: Too many arguments (6/5) (too-many-arguments)
pytorch/torch/nn/functional.py:971:11: I1101: Module 'torch._C' has no '_nn' member, but source is unavailable. Consider adding this module to extension-pkg-allow-list if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
pytorch/torch/nn/functional.py:971:11: W0212: Access to a protected member _nn of a client class (protected-access)
pytorch/torch/nn/functional.py:971:11: W0212: Access to a protected member _C of a client class (protected-access)
pytorch/torch/nn/functional.py:975:4: W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py:974:0: R0913: Too many arguments (6/5) (too-many-arguments)
pytorch/torch/nn/modules/fold.py:1:0: R0801: Similar lines in 2 files
==torch.nn.intrinsic.qat.modules.conv_fused:[53:75]
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we include the bellow lines?

Copy link
Author

Choose a reason for hiding this comment

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

I wasn’t sure what the matching format should be to fit it. Any suggestions?

==torch.nn.intrinsic.qat.modules.linear_fused:[44:66]
else:
self.register_parameter('bias', None)
self.reset_bn_parameters()

# this needs to be called after reset_bn_parameters,
# as they modify the same state
if self.training:
if freeze_bn:
self.freeze_bn_stats()
else:
self.update_bn_stats()
else:
self.freeze_bn_stats()

def reset_running_stats(self):
self.bn.reset_running_stats()

def reset_bn_parameters(self):
self.bn.reset_running_stats()
init.uniform_(self.bn.weight)
init.zeros_(self.bn.bias)
# note: below is actully for conv, not BN (duplicate-code)
44 changes: 44 additions & 0 deletions fmts/testdata/pylint.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
|| ************* Module torch.nn.functional
pytorch/torch/nn/functional.py|874 col 4| W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py|878 col 4| C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate)
pytorch/torch/nn/functional.py|878 col 8| C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
pytorch/torch/nn/functional.py|887 col 16| C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pytorch/torch/nn/functional.py|892 col 12| C0103: Variable name "d" doesn't conform to snake_case naming style (invalid-name)
pytorch/torch/nn/functional.py|897 col 20| C0209: Formatting a regular string which could be a f-string (consider-using-f-string)
pytorch/torch/nn/functional.py|907 col 4| W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py|906| R0913: Too many arguments (6/5) (too-many-arguments)
pytorch/torch/nn/functional.py|939 col 11| I1101: Module 'torch._C' has no '_nn' member, but source is unavailable. Consider adding this module to extension-pkg-allow-list if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
pytorch/torch/nn/functional.py|939 col 11| W0212: Access to a protected member _nn of a client class (protected-access)
pytorch/torch/nn/functional.py|939 col 11| W0212: Access to a protected member _C of a client class (protected-access)
pytorch/torch/nn/functional.py|943 col 4| W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py|942| R0913: Too many arguments (6/5) (too-many-arguments)
pytorch/torch/nn/functional.py|971 col 11| I1101: Module 'torch._C' has no '_nn' member, but source is unavailable. Consider adding this module to extension-pkg-allow-list if you want to perform analysis based on run-time introspection of living objects. (c-extension-no-member)
pytorch/torch/nn/functional.py|971 col 11| W0212: Access to a protected member _nn of a client class (protected-access)
pytorch/torch/nn/functional.py|971 col 11| W0212: Access to a protected member _C of a client class (protected-access)
pytorch/torch/nn/functional.py|975 col 4| W0622: Redefining built-in 'input' (redefined-builtin)
pytorch/torch/nn/functional.py|974| R0913: Too many arguments (6/5) (too-many-arguments)
pytorch/torch/nn/modules/fold.py|1| R0801: Similar lines in 2 files
|| ==torch.nn.intrinsic.qat.modules.conv_fused:[53:75]
|| ==torch.nn.intrinsic.qat.modules.linear_fused:[44:66]
|| else:
|| self.register_parameter('bias', None)
|| self.reset_bn_parameters()
||
|| # this needs to be called after reset_bn_parameters,
|| # as they modify the same state
|| if self.training:
|| if freeze_bn:
|| self.freeze_bn_stats()
|| else:
|| self.update_bn_stats()
|| else:
|| self.freeze_bn_stats()
||
|| def reset_running_stats(self):
|| self.bn.reset_running_stats()
||
|| def reset_bn_parameters(self):
|| self.bn.reset_running_stats()
|| init.uniform_(self.bn.weight)
|| init.zeros_(self.bn.bias)
|| # note: below is actully for conv, not BN (duplicate-code)