Skip to content

Commit cde2aad

Browse files
committed
Blacken the source code and add black configuration.
- Add configuration file for black's settings. - Add a shield for black's codestyle. - Run black over the entire codebase.
1 parent fabd548 commit cde2aad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+4513
-3371
lines changed

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
.. |ImageLink| image:: https://travis-ci.org/bpython/bpython.svg?branch=master
44
.. _ImageLink: https://travis-ci.org/bpython/bpython
55

6+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
7+
:target: https://github.com/ambv/black
8+
69
***********************************************************************
710
bpython: A fancy curses interface to the Python interactive interpreter
811
***********************************************************************

bpython/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,16 @@
2727
try:
2828
from ._version import __version__ as version
2929
except ImportError:
30-
version = 'unknown'
30+
version = "unknown"
3131

3232
__version__ = version
3333
package_dir = os.path.abspath(os.path.dirname(__file__))
3434

3535

3636
def embed(locals_=None, args=None, banner=None):
3737
if args is None:
38-
args = ['-i', '-q']
38+
args = ["-i", "-q"]
3939

4040
from .curtsies import main
41+
4142
return main(args, locals_, banner)

bpython/__main__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import sys
2828

29-
if __name__ == '__main__':
29+
if __name__ == "__main__":
3030
from .curtsies import main
31+
3132
sys.exit(main())

bpython/_internal.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class _Helper(object):
15-
1615
def __init__(self):
1716
if hasattr(pydoc.Helper, "output"):
1817
# See issue #228
@@ -21,8 +20,10 @@ def __init__(self):
2120
self.helper = pydoc.Helper(sys.stdin, sys.stdout)
2221

2322
def __repr__(self):
24-
return ("Type help() for interactive help, "
25-
"or help(object) for help about object.")
23+
return (
24+
"Type help() for interactive help, "
25+
"or help(object) for help about object."
26+
)
2627

2728
def __call__(self, *args, **kwargs):
2829
self.helper(*args, **kwargs)

bpython/_py3compat.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import sys
4040
import threading
4141

42-
py3 = (sys.version_info[0] == 3)
42+
py3 = sys.version_info[0] == 3
4343

4444

4545
if py3:
@@ -49,17 +49,25 @@
4949

5050

5151
if py3 or sys.version_info[:3] >= (2, 7, 3):
52+
5253
def prepare_for_exec(arg, encoding=None):
5354
return arg
55+
56+
5457
else:
58+
5559
def prepare_for_exec(arg, encoding=None):
5660
return arg.encode(encoding)
5761

5862

5963
if py3:
64+
6065
def try_decode(s, encoding):
6166
return s
67+
68+
6269
else:
70+
6371
def try_decode(s, encoding):
6472
"""Try to decode s which is str names. Return None if not decodable"""
6573
if not isinstance(s, unicode):
@@ -71,8 +79,12 @@ def try_decode(s, encoding):
7179

7280

7381
if py3:
82+
7483
def is_main_thread():
7584
return threading.main_thread() == threading.current_thread()
85+
86+
7687
else:
88+
7789
def is_main_thread():
7890
return isinstance(threading.current_thread(), threading._MainThread)

bpython/args.py

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ def error(self, msg):
2727

2828

2929
def version_banner():
30-
return 'bpython version %s on top of Python %s %s' % (
31-
__version__, sys.version.split()[0], sys.executable)
30+
return "bpython version %s on top of Python %s %s" % (
31+
__version__,
32+
sys.version.split()[0],
33+
sys.executable,
34+
)
3235

3336

3437
def parse(args, extras=None, ignore_stdin=False):
@@ -60,24 +63,43 @@ def parse(args, extras=None, ignore_stdin=False):
6063
args = sys.argv[1:]
6164

6265
parser = RaisingOptionParser(
63-
usage=_('Usage: %prog [options] [file [args]]\n'
64-
'NOTE: If bpython sees an argument it does '
65-
'not know, execution falls back to the '
66-
'regular Python interpreter.'))
66+
usage=_(
67+
"Usage: %prog [options] [file [args]]\n"
68+
"NOTE: If bpython sees an argument it does "
69+
"not know, execution falls back to the "
70+
"regular Python interpreter."
71+
)
72+
)
6773
# This is not sufficient if bpython gains its own -m support
6874
# (instead of falling back to Python itself for that).
6975
# That's probably fixable though, for example by having that
7076
# option swallow all remaining arguments in a callback.
7177
parser.disable_interspersed_args()
72-
parser.add_option('--config', default=default_config_path(),
73-
help=_('Use CONFIG instead of default config file.'))
74-
parser.add_option('--interactive', '-i', action='store_true',
75-
help=_('Drop to bpython shell after running file '
76-
'instead of exiting.'))
77-
parser.add_option('--quiet', '-q', action='store_true',
78-
help=_("Don't flush the output to stdout."))
79-
parser.add_option('--version', '-V', action='store_true',
80-
help=_('Print version and exit.'))
78+
parser.add_option(
79+
"--config",
80+
default=default_config_path(),
81+
help=_("Use CONFIG instead of default config file."),
82+
)
83+
parser.add_option(
84+
"--interactive",
85+
"-i",
86+
action="store_true",
87+
help=_(
88+
"Drop to bpython shell after running file " "instead of exiting."
89+
),
90+
)
91+
parser.add_option(
92+
"--quiet",
93+
"-q",
94+
action="store_true",
95+
help=_("Don't flush the output to stdout."),
96+
)
97+
parser.add_option(
98+
"--version",
99+
"-V",
100+
action="store_true",
101+
help=_("Print version and exit."),
102+
)
81103

82104
if extras is not None:
83105
extras_group = OptionGroup(parser, extras[0], extras[1])
@@ -93,8 +115,10 @@ def parse(args, extras=None, ignore_stdin=False):
93115

94116
if options.version:
95117
print(version_banner())
96-
print('(C) 2008-2016 Bob Farrell, Andreas Stuehrk, Sebastian Ramacher, Thomas Ballinger, et al. '
97-
'See AUTHORS for detail.')
118+
print(
119+
"(C) 2008-2016 Bob Farrell, Andreas Stuehrk, Sebastian Ramacher, Thomas Ballinger, et al. "
120+
"See AUTHORS for detail."
121+
)
98122
raise SystemExit
99123

100124
if not ignore_stdin and not (sys.stdin.isatty() and sys.stdout.isatty()):
@@ -113,13 +137,13 @@ def exec_code(interpreter, args):
113137
Helper to execute code in a given interpreter. args should be a [faked]
114138
sys.argv
115139
"""
116-
with open(args[0], 'r') as sourcefile:
140+
with open(args[0], "r") as sourcefile:
117141
source = sourcefile.read()
118142
old_argv, sys.argv = sys.argv, args
119143
sys.path.insert(0, os.path.abspath(os.path.dirname(args[0])))
120-
mod = imp.new_module('__console__')
121-
sys.modules['__console__'] = mod
144+
mod = imp.new_module("__console__")
145+
sys.modules["__console__"] = mod
122146
interpreter.locals = mod.__dict__
123-
interpreter.locals['__file__'] = args[0]
124-
interpreter.runsource(source, args[0], 'exec')
147+
interpreter.locals["__file__"] = args[0]
148+
interpreter.runsource(source, args[0], "exec")
125149
sys.argv = old_argv

0 commit comments

Comments
 (0)