Skip to content

Commit 037e9db

Browse files
committed
Removce flake8 things
1 parent 4394d9b commit 037e9db

File tree

4 files changed

+25
-21
lines changed

4 files changed

+25
-21
lines changed

mathicsscript/__main__.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,25 @@
66
import subprocess
77
import sys
88
from pathlib import Path
9+
from typing import Any
910

1011
import click
11-
from mathics.core.attributes import attribute_string_to_number
12-
from pygments import highlight
13-
1412
from mathics import license_string, settings, version_info
13+
from mathics.core.attributes import attribute_string_to_number
1514
from mathics.core.definitions import autoload_files
1615
from mathics.core.evaluation import Evaluation, Output
1716
from mathics.core.expression import from_python
1817
from mathics.core.parser import MathicsFileLineFeeder
1918
from mathics.core.symbols import Symbol, SymbolFalse, SymbolTrue
20-
2119
from mathics_scanner import replace_wl_with_plain_text
20+
from pygments import highlight
2221

2322
from mathicsscript.asymptote import asymptote_version
23+
from mathicsscript.settings import definitions
2424
from mathicsscript.termshell import ShellEscapeException, mma_lexer
2525
from mathicsscript.termshell_gnu import TerminalShellGNUReadline
2626
from mathicsscript.termshell_prompt import TerminalShellPromptToolKit
27+
from mathicsscript.version import __version__
2728

2829
try:
2930
__import__("readline")
@@ -66,10 +67,6 @@ def get_srcdir():
6667
return osp.realpath(filename)
6768

6869

69-
from mathicsscript.settings import definitions
70-
from mathicsscript.version import __version__
71-
72-
7370
def ensure_settings():
7471
home = Path.home()
7572
base_config_dir = home / ".config"
@@ -169,7 +166,8 @@ def out(self, out):
169166
type=click.Choice(readline_choices, case_sensitive=False),
170167
default="Prompt",
171168
show_default=True,
172-
help="""Readline method. "Prompt" is usually best. None is generally available and have the fewest features.""",
169+
help="""Readline method. "Prompt" is usually best. None is generally available and """
170+
"""have the fewest features.""",
173171
)
174172
@click.option(
175173
"--completion/--no-completion",
@@ -233,7 +231,7 @@ def out(self, out):
233231
@click.option(
234232
"--strict-wl-output/--no-strict-wl-output",
235233
default=False,
236-
help=("Most WL-output compatible (at the expense of useability)."),
234+
help=("Most WL-output compatible (at the expense of usability)."),
237235
required=False,
238236
)
239237
@click.argument("file", nargs=1, type=click.Path(readable=True), required=False)
@@ -377,6 +375,12 @@ def main(
377375
)
378376
TeXForm = Symbol("System`TeXForm")
379377

378+
def identity(x: Any) -> Any:
379+
return x
380+
381+
def fmt_fun(query: Any) -> Any:
382+
return highlight(str(query), mma_lexer, shell.terminal_formatter)
383+
380384
definitions.set_line_no(0)
381385
while True:
382386
try:
@@ -389,13 +393,11 @@ def main(
389393
"Settings`$ShowFullFormInput"
390394
).replace.to_python()
391395
style = definitions.get_ownvalue("Settings`$PygmentsStyle")
392-
fmt = lambda x: x
396+
fmt = identity
393397
if style:
394398
style = style.replace.get_string_value()
395399
if shell.terminal_formatter:
396-
fmt = lambda x: highlight(
397-
str(query), mma_lexer, shell.terminal_formatter
398-
)
400+
fmt = fmt_fun
399401

400402
evaluation = Evaluation(shell.definitions, output=TerminalOutput(shell))
401403
query, source_code = evaluation.parse_feeder_returning_code(shell)
@@ -444,7 +446,7 @@ def main(
444446
# Should we test exit code for adding to history?
445447
GNU_readline.add_history(source_code.rstrip())
446448
# FIXME add this... when in Mathics core updated
447-
# shell.defintions.increment_line(1)
449+
# shell.definitions.increment_line(1)
448450

449451
except (KeyboardInterrupt):
450452
print("\nKeyboardInterrupt")

mathicsscript/asymptote.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def help(self):
8686

8787
def __del__(self):
8888
# print("closing Asymptote session...")
89-
# Popen in __init__ can fail (e.g. asymptote is not intalled), so self
90-
# potentially does not have a sesion attribute and without this check an
89+
# Popen in __init__ can fail (e.g. asymptote is not installed), so self
90+
# potentially does not have a session attribute and without this check an
9191
# AttributeError can get logged
9292
if hasattr(self, "session"):
9393
self.send("quit")

mathicsscript/fake_psviewer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
which does nothing, but remove any file argument it is
66
given.
77
8-
Asymptote run via mathicsscript will create an embeded postscript file out.eps
8+
Asymptote run via mathicsscript will create an embedded postscript file out.eps
99
which should be removed.
1010
"""
1111
import os

mathicsscript/format.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def hierarchy_pos(
264264
return cached_pair
265265

266266
# These get swapped if tree edge directions point to the root.
267-
decendants = nx.descendants
267+
descendants = nx.descendants
268268
out_degree = G.out_degree if hasattr(G, "out_degree") else G.degree
269269
neighbors = G.neighbors
270270

@@ -276,7 +276,7 @@ def hierarchy_pos(
276276
# The case where we have a one or two node graph is ambiguous.
277277
root = list(nx.topological_sort(G))[-1]
278278
# Swap motion functions
279-
decendants = nx.ancestors
279+
descendants = nx.ancestors
280280
out_degree = G.in_degree
281281
neighbors = G.predecessors
282282
else:
@@ -351,7 +351,9 @@ def _hierarchy_pos(
351351

352352
xcenter = width / 2.0
353353
if isinstance(G, nx.DiGraph):
354-
leafcount = len([node for node in decendants(G, root) if out_degree(node) == 0])
354+
leafcount = len(
355+
[node for node in descendants(G, root) if out_degree(node) == 0]
356+
)
355357
elif isinstance(G, nx.Graph):
356358
leafcount = len(
357359
[

0 commit comments

Comments
 (0)