Skip to content

Commit cbaa06e

Browse files
committed
blackify
1 parent ec8ffc0 commit cbaa06e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

handcalcs/decorator.py

+18-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ def handcalc(
1818
):
1919
def handcalc_decorator(func):
2020
if record:
21-
decorated = HandcalcsCallRecorder(func, override, precision, left, right, scientific_notation, jupyter_display)
21+
decorated = HandcalcsCallRecorder(
22+
func,
23+
override,
24+
precision,
25+
left,
26+
right,
27+
scientific_notation,
28+
jupyter_display,
29+
)
2230
else:
31+
2332
@wraps(func)
2433
def decorated(*args, **kwargs):
2534
line_args = {
@@ -33,7 +42,9 @@ def decorated(*args, **kwargs):
3342
scope = innerscope.call(func, *args, **kwargs)
3443
renderer = LatexRenderer(cell_source, scope, line_args)
3544
latex_code = renderer.render()
36-
raw_latex_code = "".join(latex_code.replace("\\[", "", 1).rsplit("\\]", 1))
45+
raw_latex_code = "".join(
46+
latex_code.replace("\\[", "", 1).rsplit("\\]", 1)
47+
)
3748
if jupyter_display:
3849
try:
3950
from IPython.display import Latex, display
@@ -44,24 +55,27 @@ def decorated(*args, **kwargs):
4455
display(Latex(latex_code))
4556
return scope.return_value
4657
return (left + raw_latex_code + right, scope.return_value)
58+
4759
return decorated
60+
4861
return handcalc_decorator
4962

5063

5164
class HandcalcsCallRecorder:
5265
"""
5366
Records function calls for the func stored in .callable
5467
"""
68+
5569
def __init__(
56-
self,
70+
self,
5771
func: Callable,
5872
_override: str = "",
5973
_precision: int = 3,
6074
_left: str = "",
6175
_right: str = "",
6276
_scientific_notation: Optional[bool] = None,
6377
_jupyter_display: bool = False,
64-
):
78+
):
6579
self.callable = func
6680
self.history = list()
6781
self._override = _override

0 commit comments

Comments
 (0)