Skip to content

Commit

Permalink
black weirdness wars (#1015)
Browse files Browse the repository at this point in the history
In some versions, black seems to want optional "," at the end of the
last parameter.

In support of getting #1013 to build cleanly
  • Loading branch information
rocky authored Mar 2, 2024
1 parent 8436347 commit 959935e
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 38 deletions.
2 changes: 1 addition & 1 deletion mathics/builtin/colors/color_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def result():
yield to_expression(
Symbol(out_palette_head),
*prototype,
elements_conversion_fn=MachineReal
elements_conversion_fn=MachineReal,
)

return to_mathics_list(*itertools.islice(result(), 0, at_most))
Expand Down
8 changes: 4 additions & 4 deletions mathics/builtin/drawing/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def eval(
functions,
xexpr_limits,
yexpr_limits,
*options_to_rules(options)
*options_to_rules(options),
)

functions = self.get_functions_param(functions)
Expand Down Expand Up @@ -1501,7 +1501,7 @@ def final_graphics(self, graphics, options):
return Expression(
SymbolGraphics,
ListExpression(*graphics),
*options_to_rules(options, Graphics.options)
*options_to_rules(options, Graphics.options),
)


Expand Down Expand Up @@ -1936,7 +1936,7 @@ def auto_bins():
return Expression(
SymbolGraphics,
ListExpression(*graphics),
*options_to_rules(options, Graphics.options)
*options_to_rules(options, Graphics.options),
)


Expand Down Expand Up @@ -2622,5 +2622,5 @@ def final_graphics(self, graphics, options: dict):
return Expression(
SymbolGraphics3D,
ListExpression(*graphics),
*options_to_rules(options, Graphics3D.options)
*options_to_rules(options, Graphics3D.options),
)
2 changes: 1 addition & 1 deletion mathics/builtin/fileformats/htmlformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def xml_object(tree):
return Expression(
Expression(SymbolXMLObject, String("Document")),
to_mathics_list(*declaration),
*node_to_xml_element(tree.getroot())
*node_to_xml_element(tree.getroot()),
)


Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/fileformats/xmlformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def xml_object(root):
return Expression(
to_expression("XMLObject", String("Document")),
to_mathics_list(*declaration),
*node_to_xml_element(root)
*node_to_xml_element(root),
)


Expand Down
8 changes: 4 additions & 4 deletions mathics/builtin/files_io/importexport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ def eval_elements(self, filename, expr, elems, evaluation, options={}):
exporter_symbol,
filename,
expr,
*list(chain(stream_options, custom_options))
*list(chain(stream_options, custom_options)),
)
res = exporter_function.evaluate(evaluation)
elif function_channels == ListExpression(String("Streams")):
Expand All @@ -1840,7 +1840,7 @@ def eval_elements(self, filename, expr, elems, evaluation, options={}):
exporter_symbol,
stream,
expr,
*list(chain(stream_options, custom_options))
*list(chain(stream_options, custom_options)),
)
res = exporter_function.evaluate(evaluation)
Expression(SymbolClose, stream).evaluate(evaluation)
Expand Down Expand Up @@ -1967,7 +1967,7 @@ def eval_elements(self, expr, elems, evaluation: Evaluation, **options):
exporter_symbol,
filename,
expr,
*list(chain(stream_options, custom_options))
*list(chain(stream_options, custom_options)),
)
exportres = exporter_function.evaluate(evaluation)
if exportres != SymbolNull:
Expand Down Expand Up @@ -2013,7 +2013,7 @@ def eval_elements(self, expr, elems, evaluation: Evaluation, **options):
exporter_symbol,
outstream,
expr,
*list(chain(stream_options, custom_options))
*list(chain(stream_options, custom_options)),
)
res = exporter_function.evaluate(evaluation)
if res is SymbolNull:
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def evaluate_predicate(pred, evaluation):
if pred.has_form(("List", "Sequence"), None):
return Expression(
pred._head,
*[evaluate_predicate(subp, evaluation) for subp in pred.elements]
*[evaluate_predicate(subp, evaluation) for subp in pred.elements],
)

debug_logical_expr("reducing ", pred, evaluation)
Expand Down
6 changes: 3 additions & 3 deletions mathics/builtin/numbers/algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ def eval_list(self, polys, varlist, evaluation: Evaluation, options: dict):
SymbolTable,
Integer(0),
ListExpression(Integer(dim1)),
*its2
*its2,
)
else:
newtable = Expression(SymbolTable, Integer(0), *its2)
Expand Down Expand Up @@ -952,7 +952,7 @@ def eval(self, expr, form, evaluation):
self.__class__.__name__, expr, form, Integer(n), evaluation
)
for n in range(dimensions[0] + 1)
]
],
)
elif form.has_form("List", 1):
form = form.elements[0]
Expand All @@ -963,7 +963,7 @@ def eval(self, expr, form, evaluation):
self.__class__.__name__, expr, form, Integer(n), evaluation
)
for n in range(dimensions[0] + 1)
]
],
)
else:

Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/numbers/diffeqns.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def eval(self, eqn, y, x, evaluation: Evaluation):
Expression(
SymbolFunction,
function_form,
*from_sympy(soln).elements[1:]
*from_sympy(soln).elements[1:],
),
),
)
Expand Down
12 changes: 6 additions & 6 deletions mathics/builtin/patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ def match(
head=None,
element_index=None,
element_count=None,
**kwargs
**kwargs,
):
if expression.has_form("Sequence", 0):
if self.default is None:
Expand Down Expand Up @@ -1231,7 +1231,7 @@ def match(
expression: Expression,
vars: dict,
evaluation: Evaluation,
**kwargs
**kwargs,
):
if not expression.has_form("Sequence", 0):
if self.head is not None:
Expand Down Expand Up @@ -1286,7 +1286,7 @@ def match(
expression: Expression,
vars: dict,
evaluation: Evaluation,
**kwargs
**kwargs,
):
elements = expression.get_sequence()
if not elements:
Expand Down Expand Up @@ -1335,7 +1335,7 @@ def match(
expression: Expression,
vars: dict,
evaluation: Evaluation,
**kwargs
**kwargs,
):
elements = expression.get_sequence()
if self.head:
Expand Down Expand Up @@ -1553,7 +1553,7 @@ def match(
expression: Expression,
vars: dict,
evaluation: Evaluation,
**kwargs
**kwargs,
):
# for new_vars, rest in self.pattern.match(expression, vars,
# evaluation):
Expand Down Expand Up @@ -1626,7 +1626,7 @@ def match(
expression: Expression,
vars: dict,
evaluation: Evaluation,
**kwargs
**kwargs,
):
if self.defaults is None:
self.defaults = kwargs.get("head")
Expand Down
12 changes: 6 additions & 6 deletions mathics/builtin/pympler/asizeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -2390,7 +2390,7 @@ def print_largest(self, w=0, cutoff=0, **print3options):
self._ranked,
s,
_SI(s),
**print3options
**print3options,
)
id2x = dict((r.id, i) for i, r in enumerate(self._ranks))
for r in self._ranks[:n]:
Expand Down Expand Up @@ -2428,7 +2428,7 @@ def print_profiles(self, w=0, cutoff=0, **print3options):
_plural(len(t)),
s,
self._incl,
**print3options
**print3options,
)
r = len(t)
for v, k in sorted(t, reverse=True):
Expand Down Expand Up @@ -2498,7 +2498,7 @@ def print_stats(
_SI(z),
self._incl,
self._repr(o),
**print3options
**print3options,
)
else:
if objs:
Expand Down Expand Up @@ -2531,7 +2531,7 @@ def print_summary(self, w=0, objs=(), **print3options):
self._total,
_SI(self._total),
self._incl,
**print3options
**print3options,
)
if self._mask:
self._printf("%*d byte aligned", w, self._mask + 1, **print3options)
Expand Down Expand Up @@ -2581,7 +2581,7 @@ def print_typedefs(self, w=0, **print3options):
len(t),
k,
_plural(len(t)),
**print3options
**print3options,
)
for a, v in sorted(t):
self._printf("%*s %s: %s", w, "", a, v, **print3options)
Expand Down Expand Up @@ -2612,7 +2612,7 @@ def reset(
limit=100,
stats=0,
stream=None,
**extra
**extra,
):
"""Reset sizing options, state, etc. to defaults.
Expand Down
6 changes: 3 additions & 3 deletions mathics/core/convert/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def make_expression(head, *elements, **kwargs) -> Expression:
def to_expression(
head: Union[str, Symbol],
*elements: Any,
elements_conversion_fn: Callable = from_python
elements_conversion_fn: Callable = from_python,
) -> Expression:
"""
This is an expression constructor that can be used when the Head and elements are not Mathics
Expand All @@ -45,14 +45,14 @@ def to_expression(
head,
*elements_tuple,
elements_properties=elements_properties,
literal_values=literal_values
literal_values=literal_values,
)


def to_expression_with_specialization(
head: Union[str, Symbol],
*elements: Any,
elements_conversion_fn: Callable = from_python
elements_conversion_fn: Callable = from_python,
) -> Union[ListExpression, Expression]:
"""
This expression constructor will figure out what the right kind of
Expand Down
4 changes: 2 additions & 2 deletions mathics/core/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ def match_element(
candidates,
included=element_candidates,
less_first=less_first,
*set_lengths
*set_lengths,
)
else:
# a generator that yields partitions of
Expand All @@ -794,7 +794,7 @@ def match_element(
flexible_start=first and not fully,
included=element_candidates,
less_first=less_first,
*set_lengths
*set_lengths,
)
if rest_elements:
next_element = rest_elements[0]
Expand Down
2 changes: 1 addition & 1 deletion mathics/core/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def yield_match(vars, rest):
if rest[0] or rest[1]:
result = Expression(
expression.get_head(),
*list(chain(rest[0], [new_expression], rest[1]))
*list(chain(rest[0], [new_expression], rest[1])),
)
else:
result = new_expression
Expand Down
2 changes: 1 addition & 1 deletion mathics/core/subexpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def elements(self, value):
def to_expression(self):
return Expression(
self._headp.to_expression(),
*(element.to_expression() for element in self._elementsp)
*(element.to_expression() for element in self._elementsp),
)

def replace(self, new):
Expand Down
2 changes: 1 addition & 1 deletion mathics/eval/numbers/calculus/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def build_series(f, x, x0, n, evaluation):
*[
build_series(element, x, x0, Integer(n), evaluation)
for element in f.elements
]
],
)
data.append(newcoeff)
data = ListExpression(*data).evaluate(evaluation)
Expand Down
2 changes: 1 addition & 1 deletion test/core/test_expression_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def attribute_check(e, varname: str):
e4 = Expression(
SymbolPlus,
*integer_ones,
elements_properties=ElementsProperties(True, True, True)
elements_properties=ElementsProperties(True, True, True),
)
attribute_check(e4, "e4")
assert e1 == e4
Expand Down
2 changes: 1 addition & 1 deletion test/core/test_sympy_python_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def testConvertedFunctions(self):
self.compare(
Expression(SymbolD, marg2, Symbol("Global`x")),
sympy.Derivative(sarg2, sympy.Symbol("_Mathics_User_Global`x")),
**kwargs
**kwargs,
)

def testExpression(self):
Expand Down

0 comments on commit 959935e

Please sign in to comment.