-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #209 from zacbrannelly/enhance/custom-checkers
ENHANCE: Add custom check for print statements
- Loading branch information
Showing
6 changed files
with
53 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,19 @@ | |
author='Scott Barnett', | ||
author_email='[email protected]', | ||
include_package_data=True, | ||
packages=['surround', 'templates', 'surround.remote', 'surround.split', 'surround.visualise', 'surround.data', 'surround.data.cli', 'surround.configuration', 'surround.experiment', 'surround.experiment.web'], | ||
packages=[ | ||
'surround', | ||
'templates', | ||
'surround.remote', | ||
'surround.split', | ||
'surround.visualise', | ||
'surround.data', | ||
'surround.data.cli', | ||
'surround.configuration', | ||
'surround.experiment', | ||
'surround.experiment.web', | ||
'surround.checkers' | ||
], | ||
test_suite='surround.tests', | ||
entry_points={ | ||
'console_scripts': [ | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from pylint import checkers | ||
from pylint import interfaces | ||
from pylint.checkers import utils | ||
|
||
class SurroundChecker(checkers.BaseChecker): | ||
__implements__ = interfaces.IAstroidChecker | ||
|
||
name = 'surround-convention' | ||
|
||
msgs = { | ||
'CS001': ( | ||
"Use of print instead of logging statements", | ||
'surround-avoid-print', | ||
'Used when a script uses print instead of a logging statement', | ||
) | ||
} | ||
|
||
@utils.check_messages('surround-avoid-print') | ||
def visit_call(self, node): | ||
if node.func.as_string() == "print": | ||
self.add_message('surround-avoid-print', node=node) | ||
|
||
def register(linter): | ||
linter.register_checker(SurroundChecker(linter)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters