Skip to content

Commit ce16747

Browse files
author
Release Manager
committed
gh-39143: fix linter warnings in sage_setup and sage_docbuild this is fixing some pycodestyle warnings that have appeared during #39134 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #39143 Reported by: Frédéric Chapoton Reviewer(s):
2 parents 661743b + f1c9349 commit ce16747

File tree

12 files changed

+36
-9
lines changed

12 files changed

+36
-9
lines changed

src/sage_docbuild/conf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ def linkcode_resolve(domain, info):
670670
# used when building html version
671671
pngmath_latex_preamble += macro + '\n'
672672

673+
673674
# ------------------------------------------
674675
# add custom context variables for templates
675676
# ------------------------------------------
@@ -712,10 +713,12 @@ def add_page_context(app, pagename, templatename, context, doctree):
712713

713714
dangling_debug = False
714715

716+
715717
def debug_inf(app, message):
716718
if dangling_debug:
717719
app.info(message)
718720

721+
719722
def call_intersphinx(app, env, node, contnode):
720723
r"""
721724
Call intersphinx and make links between Sage manuals relative.
@@ -749,6 +752,7 @@ def call_intersphinx(app, env, node, contnode):
749752
debug_inf(app, "---- Intersphinx: %s not Found" % node['reftarget'])
750753
return res
751754

755+
752756
def find_sage_dangling_links(app, env, node, contnode):
753757
r"""
754758
Try to find dangling link in local module imports or all.py.
@@ -859,6 +863,7 @@ def find_sage_dangling_links(app, env, node, contnode):
859863
'__builtin__',
860864
]
861865

866+
862867
def check_nested_class_picklability(app, what, name, obj, skip, options):
863868
"""
864869
Print a warning if pickling is broken for nested classes.
@@ -879,6 +884,7 @@ def check_nested_class_picklability(app, what, name, obj, skip, options):
879884
'sage.misc.nested_class.NestedClassMetaclass.' % (
880885
v.__module__ + '.' + name + '.' + nm))
881886

887+
882888
def skip_member(app, what, name, obj, skip, options):
883889
"""
884890
To suppress Sphinx warnings / errors, we

src/sage_docbuild/ext/sage_autodoc.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,12 @@
8181
is_function_or_cython_function)
8282

8383
_getdoc = getdoc
84+
85+
8486
def getdoc(obj, *args, **kwargs):
8587
return sage_getdoc_original(obj)
88+
89+
8690
# ------------------------------------------------------------------
8791

8892
if TYPE_CHECKING:
@@ -1616,7 +1620,7 @@ def can_document_member(
16161620
try:
16171621
result_bool = isinstance(member, type) or (
16181622
isattr and isinstance(member, NewType | TypeVar))
1619-
except:
1623+
except Exception:
16201624
result_bool = isinstance(member, type) or (
16211625
isattr and (inspect.isNewType(member) or isinstance(member, TypeVar)))
16221626
return result_bool
@@ -1695,7 +1699,7 @@ def import_object(self, raiseerror: bool = False) -> bool:
16951699
# support both sphinx 8 and py3.9/older sphinx
16961700
try:
16971701
test_bool = isinstance(self.object, NewType | TypeVar)
1698-
except:
1702+
except Exception:
16991703
test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar)
17001704
if test_bool:
17011705
modname = getattr(self.object, '__module__', self.modname)
@@ -1709,7 +1713,7 @@ def _get_signature(self) -> tuple[Any | None, str | None, Signature | None]:
17091713
# support both sphinx 8 and py3.9/older sphinx
17101714
try:
17111715
test_bool = isinstance(self.object, NewType | TypeVar)
1712-
except:
1716+
except Exception:
17131717
test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar)
17141718
if test_bool:
17151719
# Suppress signature
@@ -1899,7 +1903,7 @@ def add_directive_header(self, sig: str) -> None:
18991903
# support both sphinx 8 and py3.9/older sphinx
19001904
try:
19011905
test_bool = isinstance(self.object, NewType | TypeVar)
1902-
except:
1906+
except Exception:
19031907
test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar)
19041908
if test_bool:
19051909
return
@@ -1911,7 +1915,7 @@ def add_directive_header(self, sig: str) -> None:
19111915
# support both sphinx 8 and py3.9/older sphinx
19121916
try:
19131917
newtype_test = isinstance(self.object, NewType)
1914-
except:
1918+
except Exception:
19151919
newtype_test = inspect.isNewType(self.object)
19161920
if (not self.doc_as_attr and not newtype_test
19171921
and canonical_fullname and self.fullname != canonical_fullname):
@@ -2053,7 +2057,7 @@ def add_content(self, more_content: StringList | None) -> None:
20532057
# support both sphinx 8 and py3.9/older sphinx
20542058
try:
20552059
newtype_test = isinstance(self.object, NewType)
2056-
except:
2060+
except Exception:
20572061
newtype_test = inspect.isNewType(self.object)
20582062
if newtype_test:
20592063
if self.config.autodoc_typehints_format == "short":

src/sage_setup/autogen/interpreters/internal/instructions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ def instr_funcall_1arg_mpfr(name, io, op):
385385
"""
386386
return InstrSpec(name, io, code='%s(o0, i0, MPFR_RNDN);' % op)
387387

388+
388389
def instr_funcall_2args_mpc(name, io, op):
389390
r"""
390391
A helper function for creating MPC instructions with two inputs
@@ -400,6 +401,7 @@ def instr_funcall_2args_mpc(name, io, op):
400401
"""
401402
return InstrSpec(name, io, code='%s(o0, i0, i1, MPC_RNDNN);' % op)
402403

404+
403405
def instr_funcall_1arg_mpc(name, io, op):
404406
r"""
405407
A helper function for creating MPC instructions with one input

src/sage_setup/autogen/interpreters/internal/memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def string_of_addr(a):
3636
"""
3737
if isinstance(a, int):
3838
return str(a)
39-
assert(isinstance(a, MemoryChunk))
39+
assert isinstance(a, MemoryChunk)
4040
return '*%s++' % a.name
4141

4242

src/sage_setup/autogen/interpreters/internal/specs/cc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def pass_call_c_argument(self):
101101
"""
102102
return "result"
103103

104+
104105
class CCInterpreter(StackInterpreter):
105106
r"""
106107
A subclass of StackInterpreter, specifying an interpreter over

src/sage_setup/autogen/interpreters/internal/storage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@ def assign_c_from_py(self, c, py):
852852

853853
ty_mpfr = StorageTypeMPFR()
854854

855+
855856
class StorageTypeMPC(StorageTypeAutoReference):
856857
r"""
857858
StorageTypeMPC is a subtype of StorageTypeAutoReference that deals

src/sage_setup/command/sage_build_cython.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
if DEVEL:
5050
extra_compile_args.append('-ggdb')
5151

52+
5253
class sage_build_cython(Command):
5354
name = 'build_cython'
5455
description = "compile Cython extensions into C/C++ extensions"

src/sage_setup/command/sage_build_ext.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from distutils.errors import DistutilsSetupError
1616
from sage_setup.run_parallel import execute_list_of_commands
1717

18+
1819
class sage_build_ext(build_ext):
1920
def finalize_options(self):
2021
build_ext.finalize_options(self)

src/sage_setup/excepthook.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import sys
33

4+
45
def excepthook(*exc):
56
"""
67
When an error occurs, display an error message similar to the error

src/sage_setup/find.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def find_python_sources(src_dir, modules=['sage'], distributions=None,
172172
os.chdir(cwd)
173173
return python_packages, python_modules, cython_modules
174174

175+
175176
def filter_cython_sources(src_dir, distributions, exclude_distributions=None):
176177
"""
177178
Find all Cython modules in the given source directory that belong to the
@@ -221,6 +222,7 @@ def filter_cython_sources(src_dir, distributions, exclude_distributions=None):
221222

222223
return files
223224

225+
224226
def _cythonized_dir(src_dir=None, editable_install=None):
225227
"""
226228
Return the path where Cython-generated files are placed by the build system.
@@ -343,6 +345,7 @@ def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[], *,
343345

344346
return data_files
345347

348+
346349
def installed_files_by_module(site_packages, modules=('sage',)):
347350
"""
348351
Find all currently installed files

0 commit comments

Comments
 (0)