Skip to content

Commit e7ad6c0

Browse files
committed
fixup: Format Python code with Black
1 parent ada387b commit e7ad6c0

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

mathics/builtin/assignment.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ def assign_elementary(self, lhs, rhs, evaluation, tags=None, upset=False):
315315
# $Context = $Context <> "test`"
316316
#
317317
if new_context.startswith("`"):
318-
new_context = evaluation.definitions.get_current_context() + new_context.lstrip(
319-
"`"
318+
new_context = (
319+
evaluation.definitions.get_current_context()
320+
+ new_context.lstrip("`")
320321
)
321322

322323
evaluation.definitions.set_current_context(new_context)

mathics/builtin/files_io/importexport.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ class RegisterImport(Builtin):
10921092

10931093
def apply(self, formatname, function, posts, evaluation, options):
10941094
"""ImportExport`RegisterImport[formatname_String, function_, posts_,
1095-
OptionsPattern[ImportExport`RegisterImport]]"""
1095+
OptionsPattern[ImportExport`RegisterImport]]"""
10961096
evaluation.cache_result = False
10971097

10981098
if function.has_form("List", None):
@@ -1175,7 +1175,7 @@ class RegisterExport(Builtin):
11751175

11761176
def apply(self, formatname, function, evaluation, options):
11771177
"""ImportExport`RegisterExport[formatname_String, function_,
1178-
OptionsPattern[ImportExport`RegisterExport]]"""
1178+
OptionsPattern[ImportExport`RegisterExport]]"""
11791179

11801180
evaluation.cache_result = False
11811181
EXPORTERS[formatname.get_string_value()] = (function, options)

mathics/builtin/system.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ class ClearSystemCache(Builtin):
621621
<dt>'ClearSystemCache[]'
622622
<dd> Clears the internal system cache of expressions.
623623
</dl>
624-
624+
625625
"""
626626

627627
def apply_clear(self, evaluation):

mathics/core/expression.py

+26-13
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@ def from_python(arg):
144144
# return Symbol(arg)
145145
elif isinstance(arg, dict):
146146
entries = [
147-
Expression("Rule", from_python(key), from_python(arg[key]),) for key in arg
147+
Expression(
148+
"Rule",
149+
from_python(key),
150+
from_python(arg[key]),
151+
)
152+
for key in arg
148153
]
149154
return Expression(SymbolList, *entries)
150155
elif isinstance(arg, BaseExpression):
@@ -1315,7 +1320,11 @@ def evaluate(self, evaluation) -> typing.Union["Expression", "Symbol"]:
13151320
# and hence, not used.
13161321
if evaluation.cache_result and (
13171322
self.get_head_name()
1318-
in ("System`Out", "System`ToBoxes", "System`MakeBoxes",)
1323+
in (
1324+
"System`Out",
1325+
"System`ToBoxes",
1326+
"System`MakeBoxes",
1327+
)
13191328
):
13201329
evaluation.cache_result = False
13211330

@@ -1895,17 +1904,21 @@ def thread(self, evaluation, head=None) -> typing.Tuple[bool, "Expression"]:
18951904
return True, Expression(head, *leaves)
18961905

18971906
def is_numeric(self) -> bool:
1898-
return self._head.get_name() in system_symbols(
1899-
"Sqrt",
1900-
"Times",
1901-
"Plus",
1902-
"Subtract",
1903-
"Minus",
1904-
"Power",
1905-
"Abs",
1906-
"Divide",
1907-
"Sin",
1908-
) and all(leaf.is_numeric() for leaf in self._leaves)
1907+
return (
1908+
self._head.get_name()
1909+
in system_symbols(
1910+
"Sqrt",
1911+
"Times",
1912+
"Plus",
1913+
"Subtract",
1914+
"Minus",
1915+
"Power",
1916+
"Abs",
1917+
"Divide",
1918+
"Sin",
1919+
)
1920+
and all(leaf.is_numeric() for leaf in self._leaves)
1921+
)
19091922
# TODO: complete list of numeric functions, or access NumericFunction
19101923
# attribute
19111924

0 commit comments

Comments
 (0)