Skip to content

Commit 2fde486

Browse files
committed
tweak docstring, more type annotations
1 parent e3c545c commit 2fde486

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

mathics/eval/makeboxes.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,36 @@ def _boxed_string(string: str, **options):
5454
return StyleBox(String(string), **options)
5555

5656

57-
def eval_fullform_makeboxes(self, expr, evaluation, f=SymbolStandardForm):
57+
def eval_fullform_makeboxes(
58+
self, expr, evaluation: Evaluation, form=SymbolStandardForm
59+
) -> Expression:
5860
"""
5961
This function takes the definitions provided by the evaluation
6062
object, and produces a boxed form for expr.
63+
64+
Basically: MakeBoxes[expr // FullForm]
6165
"""
6266
# This is going to be reimplemented.
6367
expr = Expression(SymbolFullForm, expr)
64-
return Expression(SymbolMakeBoxes, expr, f).evaluate(evaluation)
68+
return Expression(SymbolMakeBoxes, expr, form).evaluate(evaluation)
6569

6670

67-
def eval_makeboxes(self, expr, evaluation, f=SymbolStandardForm):
71+
def eval_makeboxes(
72+
self, expr, evaluation: Evaluation, form=SymbolStandardForm
73+
) -> Expression:
6874
"""
6975
This function takes the definitions provided by the evaluation
7076
object, and produces a boxed fullform for expr.
77+
78+
Basically: MakeBoxes[expr // form]
7179
"""
7280
# This is going to be reimplemented.
73-
return Expression(SymbolMakeBoxes, expr, f).evaluate(evaluation)
81+
return Expression(SymbolMakeBoxes, expr, form).evaluate(evaluation)
7482

7583

7684
def format_element(
7785
element: BaseElement, evaluation: Evaluation, form: Symbol, **kwargs
78-
) -> BaseElement:
86+
) -> Type[BaseElement]:
7987
"""
8088
Applies formats associated to the expression, and then calls Makeboxes
8189
"""
@@ -95,14 +103,14 @@ def format_element(
95103

96104
def do_format(
97105
element: BaseElement, evaluation: Evaluation, form: Symbol
98-
) -> BaseElement:
106+
) -> Type[BaseElement]:
99107
do_format_method = element_formatters.get(type(element), do_format_element)
100108
return do_format_method(element, evaluation, form)
101109

102110

103111
def do_format_element(
104112
element: BaseElement, evaluation: Evaluation, form: Symbol
105-
) -> BaseElement:
113+
) -> Type[BaseElement]:
106114
"""
107115
Applies formats associated to the expression and removes
108116
superfluous enclosing formats.
@@ -220,7 +228,7 @@ def format_expr(expr):
220228

221229
def do_format_rational(
222230
element: BaseElement, evaluation: Evaluation, form: Symbol
223-
) -> BaseElement:
231+
) -> Type[BaseElement]:
224232
if form is SymbolFullForm:
225233
return do_format_expression(
226234
Expression(
@@ -245,7 +253,7 @@ def do_format_rational(
245253

246254
def do_format_complex(
247255
element: BaseElement, evaluation: Evaluation, form: Symbol
248-
) -> BaseElement:
256+
) -> Type[BaseElement]:
249257
if form is SymbolFullForm:
250258
return do_format_expression(
251259
Expression(
@@ -273,7 +281,7 @@ def do_format_complex(
273281

274282
def do_format_expression(
275283
element: BaseElement, evaluation: Evaluation, form: Symbol
276-
) -> BaseElement:
284+
) -> Type[BaseElement]:
277285
# # not sure how much useful is this format_cache
278286
# if element._format_cache is None:
279287
# element._format_cache = {}

0 commit comments

Comments
 (0)