Skip to content

Commit

Permalink
Punt the try/except/finally check to a future PR
Browse files Browse the repository at this point in the history
  • Loading branch information
cfournie committed Mar 6, 2017
1 parent 5c9b22b commit d6da79b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 deletions.
19 changes: 0 additions & 19 deletions shopify_python/google_styleguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ def visit_assign(self, node): # type: (astroid.Assign) -> None
def visit_excepthandler(self, node): # type: (astroid.ExceptHandler) -> None
self.__dont_catch_standard_error(node)

def visit_tryexcept(self, node): # type: (astroid.TryExcept) -> None
self.__minimize_code_in_try_except(node)

def visit_tryfinally(self, node): # type: (astroid.TryFinally) -> None
self.__minimize_code_in_finally(node)

def visit_importfrom(self, node): # type: (astroid.ImportFrom) -> None
self.__import_modules_only(node)
self.__import_full_path_only(node)
Expand Down Expand Up @@ -145,16 +139,3 @@ def __dont_catch_standard_error(self, node): # type: (astroid.ExceptHandler) ->
"""
if hasattr(node.type, 'name') and node.type.name == 'StandardError':
self.add_message('catch-standard-error', node=node)

def __minimize_code_in_try_except(self, node): # type: (astroid.TryExcept) -> None
"""Minimize the amount of code in a try/except block."""
if len(node.body) > self.max_try_exc_finally_body_size:
self.add_message('try-too-long', node=node)
for handler in node.handlers:
if len(handler.body) > self.max_try_exc_finally_body_size:
self.add_message('except-too-long', node=handler)

def __minimize_code_in_finally(self, node): # type: (astroid.TryFinally) -> None
"""Minimize the amount of code in a finally block."""
if len(node.finalbody) > self.max_try_exc_finally_body_size:
self.add_message('finally-too-long', node=node)
53 changes: 0 additions & 53 deletions tests/shopify_python/test_google_styleguide.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,56 +89,3 @@ def test_catch_blank_passes(self):
""")
with self.assertAddsMessages():
self.walk(root)

def test_try_exc_finally_size(self):
root = astroid.builder.parse("""
try:
# Comments are OK.
# They are needed to document
# complicated exception
# scenarious and should
# not be penalized.
l = 1
except AssertionError:
# Comments are OK.
# They are needed to document
# complicated exception
# scenarious and should
# not be penalized.
raise
finally:
# Comments are OK.
# They are needed to document
# complicated exception
# scenarious and should
# not be penalized.
l = 1
try:
l = 1
l = 2
l = 3
l = 4
l = 5
l = 6
except AssertionError:
l = 1
l = 2
l = 3
l = 4
l = 5
l = 6
finally:
l = 1
l = 2
l = 3
l = 4
l = 5
l = 6
""")
with self.assertAddsMessages(
pylint.testutils.Message('finally-too-long', node=root.body[1]),
pylint.testutils.Message('try-too-long', node=root.body[1].body[0]),
pylint.testutils.Message('except-too-long', node=root.body[1].body[0].handlers[0]),
):
self.walk(root)

0 comments on commit d6da79b

Please sign in to comment.