Skip to content

Commit b1dfa6e

Browse files
authored
Merge pull request #41 from Mathics3/administrivia
style kinds of things
2 parents a8ed782 + 340681c commit b1dfa6e

File tree

9 files changed

+115
-45
lines changed

9 files changed

+115
-45
lines changed

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# THis is an EditorConfig file
2+
# https://EditorConfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
insert_final_newline = true
9+
charset = utf-8
10+
indent_style = tab
11+
indent_size = 4
12+
insert_final_newline = true
13+
14+
[*.yml]
15+
indent_style = space
16+
indent_size = 2
17+
end_of_line = lf
18+
insert_final_newline = true
19+
20+
[*.py]
21+
indent_style = space
22+
indent_size = 4
23+
end_of_line = lf
24+
insert_final_newline = true
25+
26+
# Tab indentation (no size specified)
27+
[Makefile]
28+
indent_style = tab

mathicsscript/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
Copyright 2020-2021 The Mathics Team
66
"""
77
from mathicsscript.version import __version__
8+
9+
__all__ = [__version__]

mathicsscript/__main__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ def ensure_settings():
6161
try:
6262
with open(srcfn, "r") as src:
6363
buffer = src.readlines()
64-
except:
64+
except IOError:
6565
print(f"'{srcfn}' was not found.")
6666
return ""
6767
try:
6868
with open(settings_file, "w") as dst:
69-
for l in buffer:
70-
dst.write(l)
71-
except:
69+
for c in buffer:
70+
dst.write(c)
71+
except IOError:
7272
print(f" '{settings_file}' cannot be written.")
7373
return ""
7474
return settings_file
@@ -414,8 +414,8 @@ def main(
414414

415415
# Should we test exit code for adding to history?
416416
GNU_readline.add_history(source_code.rstrip())
417-
## FIXME add this... when in Mathics core updated
418-
## shell.defintions.increment_line(1)
417+
# FIXME add this... when in Mathics core updated
418+
# shell.defintions.increment_line(1)
419419

420420
except (KeyboardInterrupt):
421421
print("\nKeyboardInterrupt")

mathicsscript/termshell.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
import os
88
import os.path as osp
99
import pathlib
10-
import re
1110
import sys
1211

1312
from mathics_pygments.lexer import MathematicaLexer, MToken
14-
from mathicsscript.completion import MathicsCompleter
15-
from mathicsscript.version import __version__
1613

1714
from mathics.core.expression import (
1815
Expression,
@@ -23,10 +20,7 @@
2320
)
2421
from mathics.core.rules import Rule
2522

26-
from mathicsscript.bindkeys import bindings, read_inputrc
27-
2823
from pygments import format, highlight, lex
29-
from pygments.styles import get_style_by_name
3024
from pygments.formatters.terminal import TERMINAL_COLORS
3125
from pygments.formatters import Terminal256Formatter
3226
from pygments.styles import get_all_styles
@@ -44,7 +38,7 @@
4438

4539
from colorama import init as colorama_init
4640

47-
## FIXME: __main__ shouldn't be needed. Fix term_background
41+
# FIXME: __main__ shouldn't be needed. Fix term_background
4842
from term_background.__main__ import is_dark_background
4943

5044
# Set up mathicsscript configuration directory

mathicsscript/termshell_gnu.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
inputrc = "inputrc-unicode" if use_unicode else "inputrc-no-unicode"
7474
try:
7575
read_init_file(str(parent_dir / inputrc))
76-
except:
76+
except: # noqa
7777
pass
7878

7979
parse_and_bind("tab: complete")
@@ -84,7 +84,7 @@ def __init__(
8484
read_history_file(HISTFILE)
8585
except IOError:
8686
pass
87-
except:
87+
except: # noqa
8888
# PyPy read_history_file fails
8989
pass
9090

@@ -104,7 +104,7 @@ def complete_symbol_name(self, text, state):
104104
# any exception thrown inside the completer gets silently
105105
# thrown away otherwise
106106
print("Unhandled error in readline completion")
107-
except:
107+
except: # noqa
108108
raise
109109

110110
def _complete_named_characters(self, prefix, text, state):
@@ -154,5 +154,5 @@ def user_write_history_file(self):
154154
set_history_length(self.history_length)
155155
# print(f"Writing {HISTFILE}")
156156
write_history_file(HISTFILE)
157-
except:
157+
except: # noqa
158158
pass

mathicsscript/termshell_prompt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
from colorama import init as colorama_init
5151

52-
## FIXME: __main__ shouldn't be needed. Fix term_background
52+
# FIXME: __main__ shouldn't be needed. Fix term_background
5353
from term_background.__main__ import is_dark_background
5454

5555
HISTFILE = osp.join(CONFIGDIR, "history-ptk")

rst2html.py

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,52 +11,47 @@
1111

1212
import re
1313

14+
1415
def yield_sphinx_only_markup(lines):
1516
"""
1617
:param file_inp: a `filename` or ``sys.stdin``?
1718
:param file_out: a `filename` or ``sys.stdout`?`
1819
1920
"""
2021
substs = [
21-
## Selected Sphinx-only Roles.
22+
# Selected Sphinx-only Roles.
2223
#
23-
(r':abbr:`([^`]+)`', r'\1'),
24-
(r':ref:`([^`]+)`', r'`\1`_'),
25-
(r':term:`([^`]+)`', r'**\1**'),
26-
(r':dfn:`([^`]+)`', r'**\1**'),
27-
(r':(samp|guilabel|menuselection):`([^`]+)`', r'``\2``'),
28-
29-
30-
## Sphinx-only roles:
24+
(r":abbr:`([^`]+)`", r"\1"),
25+
(r":ref:`([^`]+)`", r"`\1`_"),
26+
(r":term:`([^`]+)`", r"**\1**"),
27+
(r":dfn:`([^`]+)`", r"**\1**"),
28+
(r":(samp|guilabel|menuselection):`([^`]+)`", r"``\2``"),
29+
# Sphinx-only roles:
3130
# :foo:`bar` --> foo(``bar``)
3231
# :a:foo:`bar` XXX afoo(``bar``)
3332
#
34-
#(r'(:(\w+))?:(\w+):`([^`]*)`', r'\2\3(``\4``)'),
35-
(r':(\w+):`([^`]*)`', r'\1(``\2``)'),
36-
37-
38-
## Sphinx-only Directives.
33+
# (r'(:(\w+))?:(\w+):`([^`]*)`', r'\2\3(``\4``)'),
34+
(r":(\w+):`([^`]*)`", r"\1(``\2``)"),
35+
# Sphinx-only Directives.
3936
#
40-
(r'\.\. doctest', r'code-block'),
41-
(r'\.\. plot::', r'.. '),
42-
(r'\.\. seealso', r'info'),
43-
(r'\.\. glossary', r'rubric'),
44-
(r'\.\. figure::', r'.. '),
45-
46-
47-
## Other
37+
(r"\.\. doctest", r"code-block"),
38+
(r"\.\. plot::", r".. "),
39+
(r"\.\. seealso", r"info"),
40+
(r"\.\. glossary", r"rubric"),
41+
(r"\.\. figure::", r".. "),
42+
# Other
4843
#
49-
(r'\|version\|', r'x.x.x'),
44+
(r"\|version\|", r"x.x.x"),
5045
]
5146

52-
regex_subs = [ (re.compile(regex, re.IGNORECASE), sub) for (regex, sub) in substs ]
47+
regex_subs = [(re.compile(regex, re.IGNORECASE), sub) for (regex, sub) in substs]
5348

5449
def clean_line(line):
5550
try:
5651
for (regex, sub) in regex_subs:
5752
line = regex.sub(sub, line)
5853
except Exception as ex:
59-
print("ERROR: %s, (line(%s)"%(regex, sub))
54+
print("ERROR: %s, (line(%s)" % (regex, sub))
6055
raise ex
6156

6257
return line

setup.cfg

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[bdist_wheel]
2+
universal = 1
3+
4+
[metadata]
5+
description_file = README.rst
6+
7+
# Recommended flake8 settings while editing zoom, we use Black for the final
8+
# linting/say in how code is formatted
9+
#
10+
# pip install flake8 flake8-bugbear
11+
#
12+
# This will warn/error on things that black does not fix, on purpose.
13+
14+
# This config file MUST be ASCII to prevent weird flake8 dropouts
15+
16+
[flake8]
17+
# max-line-length setting: NO we do not want everyone writing 120-character lines!
18+
# We are setting the maximum line length big here because there are longer
19+
# lines allowed by black in some cases that are forbidden by flake8. Since
20+
# black has the final say about code formatting issues, this setting is here to
21+
# make sure that flake8 doesn't fail the build on longer lines allowed by
22+
# black.
23+
max-line-length = 120
24+
max-complexity = 12
25+
select = E,F,W,C,B,B9
26+
ignore =
27+
# E123 closing bracket does not match indentation of opening bracket's line
28+
E123
29+
# E203 whitespace before ':' (Not PEP8 compliant, Python Black)
30+
E203
31+
# E501 line too long (82 > 79 characters) (replaced by B950 from flake8-bugbear,
32+
# https://github.com/PyCQA/flake8-bugbear)
33+
E501
34+
# W503 line break before binary operator (Not PEP8 compliant, Python Black)
35+
W503
36+
# W504 line break after binary operator (Not PEP8 compliant, Python Black)
37+
W504
38+
# C901 function too complex - since many of zz9 functions are too complex with a lot
39+
# of if branching
40+
C901
41+
# module level import not at top of file. This is too restrictive. Can't even have a
42+
# docstring higher.
43+
E402
44+
per-file-ignores =
45+
# These are config files. The `c` variable them is injected not defined.
46+
pow/ansible/roles/jupyterhub/templates/jupyterhub_config*.py:F821
47+
# Ignore some errors in files that are stolen from other projects to avoid lots
48+
# of merge problems later .
49+
pow/ansible/roles/webtier/files/supervisor_httpgroupok.py:E126,E128,E222,E225,E226,E261,E301,E302,E305,F841,E201,E202
50+
silhouette/src/silhouette/gprof2dot.py:E711,E713,E741,F401
51+
# Ignore undefined name errors in "expectation" test Python code.
52+
# These files get exec'd in an environment that defines the variables.
53+
server/tests/files/expectations/*.py:F821

test/helper.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from mathics.core.definitions import Definitions
2-
from mathics.core.evaluation import Evaluation
31
from mathics.session import MathicsSession
42

53
session = MathicsSession(add_builtin=True, catch_interrupt=False)

0 commit comments

Comments
 (0)