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

LaTeX plugin: fix type check #448

Merged
merged 3 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions v7/latex/latex/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,12 @@ def __flatten(self, block):
if isinstance(block, tree.Block):
while True:
if len(block.elements) == 1 and isinstance(block.elements[0], tree.Block):
if isinstance(block, tree.Block):
# Note that the two if conditions below cannot use isinstance()
# since we do not want to match any class derived from Block!
if type(block) is tree.Block:
block.elements[0].labels.extend(block.labels)
block = block.elements[0]
elif isinstance(block.elements[0], tree.Block):
elif type(block.elements[0]) is tree.Block:
block.labels.extend(block.elements[0].labels)
block.elements = block.elements[0].elements
else:
Expand Down
2 changes: 1 addition & 1 deletion v7/latex/latex/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def recombine_as_text(self, reescape=True):

def __str__(self):
"""Generate textual representation."""
return "TikzPicture(" + self.args + "; " + repr(self.formula) + ")"
return "TikzPicture(" + str(self.args) + "; " + repr(self.formula) + ")"

def visit(self, visitor, *args, **kw):
"""Process with TreeVisitor object. Passes ``args`` and ``kw`` to the corresponding method of ``visitor``."""
Expand Down
Loading