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

Misleading AST for modulo operator combined with multiplication #197

Open
EmilyBourne opened this issue Feb 25, 2020 · 1 comment
Open

Comments

@EmilyBourne
Copy link

When a modulo operator is combined with a multiplication redbaron does not interpret the code in the same way as python.

E.g:

a % 2 * 4

In python this is equivalent to:

(a % 2) * 4

however redbaron reads it as:

a % (2 * 4)

as shown here:

> red = RedBaron("a % 2 * 4")

> red.help(deep=True)
0 -----------------------------------------------------
BinaryOperatorNode()
  # identifiers: binary_operator, binary_operator_, binaryoperator, binaryoperatornode
  value='%'
  first ->
    NameNode()
      # identifiers: name, name_, namenode
      value='a'
  second ->
    BinaryOperatorNode()
      # identifiers: binary_operator, binary_operator_, binaryoperator, binaryoperatornode
      value='*'
      first ->
        IntNode()
          # identifiers: int, int_, intnode
          value='2'
      second ->
        IntNode()
          # identifiers: int, int_, intnode
          value='4'
@EmilyBourne
Copy link
Author

This is due to an error in baron: PyCQA/baron#162

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

No branches or pull requests

1 participant