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
Remove extra space from the unparser #10551
Conversation
I won't be able to test this with any of the big projects listed in gh-10550, but I just tried it with a personal project, with the parameter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with nits.
@tk0miya updated! A |
sphinx/pycode/ast.py
Outdated
@@ -202,7 +202,10 @@ def is_simple_tuple(value: ast.AST) -> bool: | |||
return "%s[%s]" % (self.visit(node.value), self.visit(node.slice)) | |||
|
|||
def visit_UnaryOp(self, node: ast.UnaryOp) -> str: | |||
return "%s %s" % (self.visit(node.op), self.visit(node.operand)) | |||
# UnaryOp is one of {UAdd, USub, Invert, Not}. Only Not needs a space. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think adding examples here makes the comment clearer:
# UnaryOp is one of {UAdd, USub, Invert, Not}. Only Not needs a space. | |
# UnaryOp is one of {UAdd, USub, Invert, Not}, which correspond | |
# respectively to `+x`, `-x`, `~x`, and `not x`. Only Not needs a space. |
Maybe @tupui would be willing to try re-building the SciPy docs with this PR branch to see if it fixes it there. The PyData Theme Docs don't have any API docs that use the |
Thanks Ezio, added a test of A |
sphinx/pycode/ast.py
Outdated
@@ -141,6 +141,9 @@ def visit_Attribute(self, node: ast.Attribute) -> str: | |||
return "%s.%s" % (self.visit(node.value), node.attr) | |||
|
|||
def visit_BinOp(self, node: ast.BinOp) -> str: | |||
# Special case ``**`` to now have surrounding spaces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Special case ``**`` to now have surrounding spaces. | |
# Special case ``**`` to not have surrounding spaces. |
Co-authored-by: Takeshi KOMIYA <i.tkomiya@gmail.com>
Thanks! |
Fixes #10550
@WarrenWeckesser / @choldgraf -- please would you be able to test this PR to check it works?
Feature or Bugfix
A