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 unary operators and resilience against unrecognized operators #74

Open
wants to merge 4 commits into
base: fix_binary_operator_lambda
Choose a base branch
from

Conversation

erikwright
Copy link
Contributor

@erikwright erikwright commented Jun 5, 2017

@cfournie PTAL. Solves the following:

[2017-06-03T04:28:19Z]   File "/app/.tox/pylint/src/pylint/pylint/utils.py", line 970, in walk
[2017-06-03T04:28:19Z]     cb(astroid)
[2017-06-03T04:28:19Z]   File "/app/.tox/pylint/lib/python3.5/site-packages/shopify_python/google_styleguide.py", line 145, in visit_lambda
[2017-06-03T04:28:19Z]     self.__lambda_func(node)
[2017-06-03T04:28:19Z]   File "/app/.tox/pylint/lib/python3.5/site-packages/shopify_python/google_styleguide.py", line 298, in __lambda_func
[2017-06-03T04:28:19Z]     operator = self.BINARY_OPERATORS[node.op]
[2017-06-03T04:28:19Z] KeyError: '&'

This change is Reviewable

@@ -295,10 +298,20 @@ def __lambda_func(self, node): # type: (astroid.Lambda) -> None
elif isinstance(node.body, astroid.BinOp):
if shopify_python.ast.count_tree_size(node.body) == 3 and len(node.args.args) == 2:
node = node.body
operator = self.BINARY_OPERATORS[node.op]
operator = self.BINARY_OPERATORS.get(node.op, None)
Copy link
Contributor

@cfournie cfournie Jun 5, 2017

Choose a reason for hiding this comment

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

I'm not sure how to test this while implementing all operators.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

unary_root = astroid.builder.parse("""
def unaryfnc():
unary_fail = map(lambda x: {}, [1, 2, 3, 4])
""".format(expression))
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes appear to be built upon #73; I assume that you'll rebase before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My apologies, forgot to set the base branch. It's updated now.

@erikwright erikwright changed the base branch from master to fix_binary_operator_lambda June 5, 2017 19:33
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.

2 participants