Skip to content

Commit 7cefdee

Browse files
committed
lint: some general fixes
1 parent 9267fbf commit 7cefdee

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

manim/mobject/svg/text_mobject.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
__all__ = ["Text", "Paragraph", "PangoText", "CairoText"]
44

55

6-
import re
7-
import os
86
import copy
97
import hashlib
8+
import os
9+
import re
10+
1011
import cairo
11-
import pangocffi
12-
import pangocairocffi
1312
import cairocffi
13+
import pangocairocffi
14+
import pangocffi
1415

1516
from ... import config, file_writer_config, logger
1617
from ...constants import *
@@ -390,6 +391,7 @@ def text2svg1(self):
390391
surface.finish()
391392
return file_name
392393

394+
393395
class Paragraph(VGroup):
394396
r"""Display a paragraph of text.
395397
@@ -637,7 +639,7 @@ def construct(self):
637639
"tab_width": 4,
638640
}
639641

640-
def __init__(self, text: str, **config):
642+
def __init__(self, text: str, **config): # pylint: disable=redefined-outer-name
641643
self.full2short(config)
642644
digest_config(self, config)
643645
self.original_text = text
@@ -682,20 +684,20 @@ def __init__(self, text: str, **config):
682684
if self.height is None and self.width is None:
683685
self.scale(TEXT_MOB_SCALE_FACTOR)
684686

685-
def remove_last_M(self, file_name: str): # pylint: disable=invalid-name
687+
def remove_last_M(self, file_name: str): # pylint: disable=invalid-name
686688
"""Internally used. Use to format the rendered SVG files."""
687689
with open(file_name, "r") as fpr:
688690
content = fpr.read()
689691
content = re.sub(r'Z M [^A-Za-z]*? "\/>', 'Z "/>', content)
690692
with open(file_name, "w") as fpw:
691693
fpw.write(content)
692694

693-
def find_indexes(self, word, text):
695+
def find_indexes(self, word: str, text: str):
694696
"""Internally used function. Finds the indexes of ``text`` in ``word``."""
695-
m = re.match(r"\[([0-9\-]{0,}):([0-9\-]{0,})\]", word)
696-
if m:
697-
start = int(m.group(1)) if m.group(1) != "" else 0
698-
end = int(m.group(2)) if m.group(2) != "" else len(text)
697+
temp = re.match(r"\[([0-9\-]{0,}):([0-9\-]{0,})\]", word)
698+
if temp:
699+
start = int(temp.group(1)) if temp.group(1) != "" else 0
700+
end = int(temp.group(2)) if temp.group(2) != "" else len(text)
699701
start = len(text) + start if start < 0 else start
700702
end = len(text) + end if end < 0 else end
701703
return [(start, end)]
@@ -706,7 +708,7 @@ def find_indexes(self, word, text):
706708
index = text.find(word, index + len(word))
707709
return indexes
708710

709-
def full2short(self, config):
711+
def full2short(self, config): # pylint: disable=redefined-outer-name
710712
"""Internally used function. Fomats some exapansion to short forms.
711713
text2color -> t2c
712714
text2font -> t2f
@@ -778,6 +780,8 @@ def str2weight(self, string):
778780
return pangocffi.Weight.HEAVY
779781
elif string == ULTRAHEAVY:
780782
return pangocffi.Weight.ULTRAHEAVY
783+
else:
784+
raise AttributeError("There is no Font Weight Called %s" % string)
781785

782786
def text2hash(self):
783787
"""Internally used function.
@@ -794,7 +798,8 @@ def text2hash(self):
794798
return hasher.hexdigest()[:16]
795799

796800
def text2settings(self):
797-
"""Internally used function. Converts the texts and styles to a setting for parsing."""
801+
"""Internally used function. Converts the texts and styles
802+
to a setting for parsing."""
798803
settings = []
799804
t2x = [self.t2f, self.t2s, self.t2w]
800805
for i in range(len(t2x)):

0 commit comments

Comments
 (0)