Skip to content

Commit 821a5ab

Browse files
author
Release Manager
committed
gh-35911: Pep8 in repl <!-- Please provide a concise, informative and self-explanatory title. --> <!-- Don't put issue numbers in the title. Put it in the Description below. --> <!-- For example, instead of "Fixes #12345", use "Add a new method to multiply two integers" --> ### 📚 Description just some pep8 fixes in `repl` folder <!-- Describe your changes here in detail. --> <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x ]`. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #35911 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents eec0b62 + 4a31eeb commit 821a5ab

File tree

10 files changed

+48
-42
lines changed

10 files changed

+48
-42
lines changed

src/sage/repl/display/formatter.py

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

8080
lazy_import('matplotlib.figure', 'Figure')
8181

82+
8283
class SageDisplayFormatter(DisplayFormatter):
8384

8485
def __init__(self, *args, **kwds):
@@ -194,7 +195,7 @@ def format(self, obj, include=None, exclude=None):
194195
# if it is not plain and dull
195196
if (not isinstance(obj, IPYTHON_NATIVE_TYPES) and
196197
not set(sage_format.keys()).issubset([PLAIN_TEXT]) and
197-
not isinstance(obj, Figure)):
198+
not isinstance(obj, Figure)):
198199
return sage_format, sage_metadata
199200

200201
if self.ipython_display_formatter(obj):

src/sage/repl/display/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
methods elsewhere.
77
"""
88

9-
#*****************************************************************************
9+
# ****************************************************************************
1010
# Copyright (C) 2014 Volker Braun <[email protected]>
1111
#
1212
# Distributed under the terms of the GNU General Public License (GPL)
1313
# as published by the Free Software Foundation; either version 2 of
1414
# the License, or (at your option) any later version.
15-
# http://www.gnu.org/licenses/
16-
#*****************************************************************************
15+
# https://www.gnu.org/licenses/
16+
# ****************************************************************************
1717

1818

1919
class TallListFormatter():
@@ -39,7 +39,7 @@ def _tall_list_row(self, running_lines, last_row=False):
3939
sage: format_list._tall_list_row(['a b', 'b c', 'c'])
4040
['a b', 'b c', 'c,', '']
4141
"""
42-
s=[]
42+
s = []
4343
for i, line in enumerate(running_lines):
4444
if i + 1 != len(running_lines):
4545
sep, tail = ' ', ''

src/sage/repl/ipython_kernel/install.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ def check(cls):
263263
spec = get_kernel_spec(ident)
264264
except NoSuchKernel:
265265
warnings.warn(f'no kernel named {ident} is accessible; '
266-
'check your Jupyter configuration '
267-
'(see https://docs.jupyter.org/en/latest/use/jupyter-directories.html)')
266+
'check your Jupyter configuration '
267+
'(see https://docs.jupyter.org/en/latest/use/jupyter-directories.html)')
268268
else:
269269
from pathlib import Path
270270
if Path(spec.argv[0]).resolve() != Path(os.path.join(SAGE_VENV, 'bin', 'sage')).resolve():
271271
warnings.warn(f'the kernel named {ident} does not seem to correspond to this '
272-
'installation of SageMath; check your Jupyter configuration '
273-
'(see https://docs.jupyter.org/en/latest/use/jupyter-directories.html)')
272+
'installation of SageMath; check your Jupyter configuration '
273+
'(see https://docs.jupyter.org/en/latest/use/jupyter-directories.html)')
274274

275275

276276
def have_prerequisites(debug=True):

src/sage/repl/ipython_kernel/interact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def f(x=(0, 10)):
5555
from sage.structure.element import parent
5656
import sage.rings.abc
5757
from sage.misc.lazy_import import lazy_import
58-
lazy_import("sage.plot.colors", "Color")
5958
from sage.structure.element import Matrix
59+
lazy_import("sage.plot.colors", "Color")
6060

6161

6262
class sage_interactive(interactive):

src/sage/repl/ipython_kernel/kernel.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
notebook or remote Jupyter sessions.
77
"""
88

9-
#*****************************************************************************
9+
# ***************************************************************************
1010
# Copyright (C) 2015 Volker Braun <[email protected]>
1111
#
1212
# Distributed under the terms of the GNU General Public License (GPL)
1313
# as published by the Free Software Foundation; either version 2 of
1414
# the License, or (at your option) any later version.
15-
# http://www.gnu.org/licenses/
16-
#*****************************************************************************
15+
# https://www.gnu.org/licenses/
16+
# ***************************************************************************
1717

1818
import sys
1919
from ipykernel.ipkernel import IPythonKernel
@@ -24,6 +24,7 @@
2424
from sage.repl.interpreter import SageNotebookInteractiveShell
2525
from sage.repl.ipython_extension import SageJupyterCustomizations
2626

27+
2728
class SageZMQInteractiveShell(SageNotebookInteractiveShell, ZMQInteractiveShell):
2829
pass
2930

@@ -98,7 +99,10 @@ def help_links(self):
9899
"""
99100
from sage.repl.ipython_kernel.install import SageKernelSpec
100101
identifier = SageKernelSpec.identifier()
101-
kernel_url = lambda x: 'kernelspecs/{0}/{1}'.format(identifier, x)
102+
103+
def kernel_url(x):
104+
return 'kernelspecs/{0}/{1}'.format(identifier, x)
105+
102106
return [
103107
{
104108
'text': 'Sage Documentation',

src/sage/repl/ipython_kernel/widgets_sagenb.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
# ****************************************************************************
3030

3131
from ipywidgets.widgets import (IntSlider, IntRangeSlider, FloatSlider,
32-
FloatRangeSlider, SelectionSlider,
33-
Checkbox, ToggleButtons, Dropdown)
32+
FloatRangeSlider, SelectionSlider,
33+
Checkbox, ToggleButtons, Dropdown)
3434
from .widgets import (TransformText, TransformTextarea,
35-
TransformIntSlider, TransformIntRangeSlider,
36-
TransformFloatSlider, TransformFloatRangeSlider,
37-
EvalText, EvalTextarea, SageColorPicker, Grid)
35+
TransformIntSlider, TransformIntRangeSlider,
36+
TransformFloatSlider, TransformFloatRangeSlider,
37+
EvalText, EvalTextarea, SageColorPicker, Grid)
3838
from ipywidgets.widgets.interaction import _get_min_max_value
3939
from collections.abc import Iterable, Sequence
4040
from numbers import Integral, Rational, Real
@@ -43,10 +43,10 @@
4343
from sage.arith.srange import srange
4444
import sage.rings.abc
4545

46-
Color = None
47-
4846
from .widgets import HTMLText as text_control
4947

48+
Color = None
49+
5050

5151
def input_box(default=None, label=None, type=None, width=80, height=1):
5252
"""
@@ -153,7 +153,7 @@ def input_box(default=None, label=None, type=None, width=80, height=1):
153153
if label is not None:
154154
kwds["description"] = label
155155
w = cls(**kwds)
156-
w.layout.max_width = str(width+1) + "em"
156+
w.layout.max_width = str(width + 1) + "em"
157157
return w
158158

159159

src/sage/repl/rich_output/backend_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@
3939
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
4040
"""
4141

42-
#*****************************************************************************
42+
# ****************************************************************************
4343
# Copyright (C) 2015 Volker Braun <[email protected]>
4444
#
4545
# Distributed under the terms of the GNU General Public License (GPL)
4646
# as published by the Free Software Foundation; either version 2 of
4747
# the License, or (at your option) any later version.
48-
# http://www.gnu.org/licenses/
49-
#*****************************************************************************
48+
# https://www.gnu.org/licenses/
49+
# ****************************************************************************
5050

5151
import builtins
5252
from io import StringIO

src/sage/repl/rich_output/backend_emacs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
88
"""
99

10-
#*****************************************************************************
10+
# ****************************************************************************
1111
# Copyright (C) 2015 Ivan Andrus <[email protected]>
1212
#
1313
# Distributed under the terms of the GNU General Public License (GPL)
1414
# as published by the Free Software Foundation; either version 2 of
1515
# the License, or (at your option) any later version.
1616
# https://www.gnu.org/licenses/
17-
#*****************************************************************************
17+
# ****************************************************************************
1818

1919
from sage.repl.rich_output.backend_ipython import BackendIPythonCommandline
2020
from sage.repl.rich_output.output_catalog import *

src/sage/repl/rich_output/backend_ipython.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
:mod:`sage.repl.rich_output`.
77
"""
88

9-
#*****************************************************************************
9+
# ****************************************************************************
1010
# Copyright (C) 2015 Volker Braun <[email protected]>
1111
#
1212
# Distributed under the terms of the GNU General Public License (GPL)
1313
# as published by the Free Software Foundation; either version 2 of
1414
# the License, or (at your option) any later version.
15-
# http://www.gnu.org/licenses/
16-
#*****************************************************************************
15+
# https://www.gnu.org/licenses/
16+
# ****************************************************************************
1717

1818
import os
1919
import sys
@@ -428,8 +428,7 @@ def normpath(p):
428428
return '\n<script src="{0}"></script>'.format(script)
429429

430430

431-
IFRAME_TEMPLATE = \
432-
"""
431+
IFRAME_TEMPLATE = """
433432
<iframe srcdoc="{escaped_html}"
434433
width="{width}"
435434
height="{height}"
@@ -543,35 +542,35 @@ def displayhook(self, plain_text, rich_output):
543542
'text/plain': plain_text.text.get_str(),
544543
}, {})
545544
elif isinstance(rich_output, OutputHtml):
546-
data = {'text/html': rich_output.html.get_str(),
545+
data = {'text/html': rich_output.html.get_str(),
547546
'text/plain': plain_text.text.get_str()}
548547
if rich_output.latex:
549548
data['text/latex'] = rich_output.latex.get_str()
550549
return (data, {})
551550
elif isinstance(rich_output, OutputImagePng):
552-
return ({'image/png': rich_output.png.get(),
551+
return ({'image/png': rich_output.png.get(),
553552
'text/plain': plain_text.text.get_str(),
554553
}, {})
555554
elif isinstance(rich_output, OutputImageGif):
556-
return ({'text/html': rich_output.html_fragment(),
555+
return ({'text/html': rich_output.html_fragment(),
557556
'text/plain': plain_text.text.get_str(),
558557
}, {})
559558
elif isinstance(rich_output, OutputImageJpg):
560-
return ({'image/jpeg': rich_output.jpg.get(),
561-
'text/plain': plain_text.text.get_str(),
559+
return ({'image/jpeg': rich_output.jpg.get(),
560+
'text/plain': plain_text.text.get_str(),
562561
}, {})
563562
elif isinstance(rich_output, OutputImageSvg):
564563
return ({'image/svg+xml': rich_output.svg.get(),
565-
'text/plain': plain_text.text.get_str(),
564+
'text/plain': plain_text.text.get_str(),
566565
}, {})
567566
elif isinstance(rich_output, OutputImagePdf):
568-
return ({'image/png': rich_output.png.get(),
567+
return ({'image/png': rich_output.png.get(),
569568
'text/plain': plain_text.text.get_str(),
570569
}, {})
571570
elif isinstance(rich_output, OutputSceneJmol):
572571
from sage.repl.display.jsmol_iframe import JSMolHtml
573572
jsmol = JSMolHtml(rich_output, height=500)
574-
return ({'text/html': jsmol.iframe(),
573+
return ({'text/html': jsmol.iframe(),
575574
'text/plain': plain_text.text.get_str(),
576575
}, {})
577576
elif isinstance(rich_output, OutputSceneThreejs):
@@ -581,7 +580,7 @@ def displayhook(self, plain_text, rich_output):
581580
width='100%',
582581
height=400,
583582
)
584-
return ({'text/html': iframe,
583+
return ({'text/html': iframe,
585584
'text/plain': plain_text.text.get_str(),
586585
}, {})
587586
else:

src/sage/repl/rich_output/display_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# Distributed under the terms of the GNU General Public License (GPL)
3131
# as published by the Free Software Foundation; either version 2 of
3232
# the License, or (at your option) any later version.
33-
# http://www.gnu.org/licenses/
33+
# https://www.gnu.org/licenses/
3434
# ****************************************************************************
3535

3636

@@ -45,6 +45,7 @@
4545
)
4646
from sage.repl.rich_output.preferences import DisplayPreferences
4747

48+
4849
def _required_threejs_version():
4950
"""
5051
Return the version of threejs that Sage requires.
@@ -60,6 +61,7 @@ def _required_threejs_version():
6061
with open(os.path.join(sage.env.SAGE_EXTCODE, 'threejs', 'threejs-version.txt')) as f:
6162
return f.read().strip()
6263

64+
6365
class DisplayException(Exception):
6466
"""
6567
Base exception for all rich output-related exceptions.

0 commit comments

Comments
 (0)