Skip to content

Commit

Permalink
gh-36177: fix and activate pycodestyle E305 in py files
Browse files Browse the repository at this point in the history
    
fix and activate

-  pycodestyle E305 in py files
- pycodestyle E502 in pyx file (one fix only)

### 📝 Checklist

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
    
URL: #36177
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert, Tobias Diez
  • Loading branch information
Release Manager committed Sep 10, 2023
2 parents f63a4d5 + 626b764 commit 8137704
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"python.linting.enabled": true,
// The following pycodestyle arguments are the same as the pycodestyle-minimal
// tox environnment, see the file SAGE_ROOT/src/tox.ini
"python.linting.pycodestyleArgs": ["--select= E111,E21,E222,E227,E25,E271,E303,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605"],
"python.linting.pycodestyleArgs": ["--select= E111,E21,E222,E227,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605"],
"cSpell.words": [
"furo",
"Conda",
Expand Down
1 change: 1 addition & 0 deletions src/sage/algebras/lie_algebras/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def regular_vector_fields(R):
from sage.algebras.lie_algebras.virasoro import LieAlgebraRegularVectorFields
return LieAlgebraRegularVectorFields(R)


witt = regular_vector_fields

def pwitt(R, p):
Expand Down
2 changes: 2 additions & 0 deletions src/sage/combinat/designs/bibd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ def _PBD_4_5_8_9_12_closure(B):
BB.append(X)
return BB


table_7_1 = {
0:{'t':-4,'u':16,'s':2},
1:{'t':-4,'u':17,'s':2},
Expand Down Expand Up @@ -1652,4 +1653,5 @@ def arc(self, s=2, solver=None, verbose=0, *, integrality_tolerance=1e-3):
values = p.get_values(b, convert=bool, tolerance=integrality_tolerance)
return [self._points[i] for (i,j) in values.items() if j]


BIBD = BalancedIncompleteBlockDesign
5 changes: 5 additions & 0 deletions src/sage/combinat/designs/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def MOLS_18_3():
#
# This dictionary is used by designs.mutually_orthogonal_latin_squares(k,n).


MOLS_constructions = {
10 : (2, MOLS_10_2),
12 : (5, MOLS_12_5),
Expand Down Expand Up @@ -2021,6 +2022,7 @@ def OA_10_1620():
#
# This dictionary is used by designs.orthogonal_array(k,n).


OA_constructions = {
18 : (7 , OA_7_18),
40 : (9 , OA_9_40),
Expand Down Expand Up @@ -2455,6 +2457,7 @@ def QDM_57_9_1_1_8():
# }
# }


QDM: dict[tuple[int, int], dict] = {}
for ((n,k,lmbda,mu,u),f) in [((19,6,1,1,1), QDM_19_6_1_1_1),
((21,5,1,1,1), QDM_21_5_1_1_1),
Expand Down Expand Up @@ -4018,6 +4021,7 @@ def DM_993_32_1():
G = AdditiveCyclic(993)
return G, M


DM = {
(12 ,1) : (6 ,DM_12_6_1),
(21 ,1) : (6 ,DM_21_6_1),
Expand Down Expand Up @@ -4686,6 +4690,7 @@ def BIBD_56_11_2():
D = IncidenceStructure(libgap.Orbit(G, B, libgap.OnSets))
return D._blocks


# Index of the BIBD constructions
#
# Associates to triple (v,k,lambda) a function that return a
Expand Down
1 change: 1 addition & 0 deletions src/sage/combinat/designs/difference_family.py
Original file line number Diff line number Diff line change
Expand Up @@ -3606,6 +3606,7 @@ def difference_family(v, k, l=1, existence=False, explain_construction=False, ch

return G, D


from sage.misc.rest_index_of_methods import gen_rest_table_index
import sys
__doc__ = __doc__.format(INDEX_OF_FUNCTIONS=gen_rest_table_index(sys.modules[__name__]))
1 change: 1 addition & 0 deletions src/sage/combinat/designs/ext_rep.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ def open_extrep_url(url):
else:
return f.read()


pattern_integer = re.compile(r'\d+$')
pattern_decimal = re.compile(r'-?\d+\.\d+$')
pattern_rational = re.compile(r'-?\d+/\d+$')
Expand Down
1 change: 1 addition & 0 deletions src/sage/geometry/hyperplane_arrangement/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -802,4 +802,5 @@ def Shi(self, data, K=QQ, names=None, m=1):
A.characteristic_polynomial.set_cache(charpoly)
return A


hyperplane_arrangements = HyperplaneArrangementLibrary()
1 change: 1 addition & 0 deletions src/sage/groups/abelian_gps/abelian_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1880,5 +1880,6 @@ def gen(self, n):
"""
return self._gens[n]


# We allow subclasses to override this, analogous to Element
AbelianGroup_class.Subgroup = AbelianGroup_subgroup
1 change: 1 addition & 0 deletions src/sage/groups/matrix_gps/morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def to_libgap(x):
from sage.libs.gap.libgap import libgap
return libgap(x)


lazy_import('sage.groups.libgap_morphism', 'GroupMorphism_libgap',
'MatrixGroupMorphism_im_gens', deprecation=25444)

Expand Down
2 changes: 2 additions & 0 deletions src/sage/groups/perm_gps/cubegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def create_poly(face, color):

####################################################


singmaster_indices = {
1: "ulb",
2: "ub",
Expand Down Expand Up @@ -1180,6 +1181,7 @@ def cubie_faces():

return cubies


cubie_face_list = cubie_faces()


Expand Down
2 changes: 2 additions & 0 deletions src/sage/groups/perm_gps/permgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5087,6 +5087,7 @@ def is_normal(self, other=None):
other = self.ambient_group()
return PermutationGroup_generic.is_normal(self, other)


# Allow for subclasses to use a different subgroup class
PermutationGroup_generic.Subgroup = PermutationGroup_subgroup

Expand Down Expand Up @@ -5194,5 +5195,6 @@ def orbits(self):
"""
return self._orbits


from sage.misc.rest_index_of_methods import gen_rest_table_index
__doc__ = __doc__.format(METHODS_OF_PermutationGroup_generic=gen_rest_table_index(PermutationGroup_generic))
1 change: 1 addition & 0 deletions src/sage/libs/pari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,5 @@ def _get_pari_instance():

return P


pari = _get_pari_instance()
4 changes: 2 additions & 2 deletions src/sage/matrix/matrix_polynomial_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1670,8 +1670,8 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense):
# the row-wise case (resp. column-wise case), it will be convenient to
# have leading position ncols (resp. nrows) for these zero vectors
pos_zero_vec = self.ncols() if row_wise else self.nrows()
leading_positions = [pos if pos>=0 else pos_zero_vec + 1 \
for pos in leading_positions]
leading_positions = [pos if pos >= 0 else pos_zero_vec + 1
for pos in leading_positions]
# leading positions should not have duplicates, which is equivalent to:
# once sorted, it doesn't contain a pair of equal successive entries
if not ordered:
Expand Down
1 change: 1 addition & 0 deletions src/sage/modular/arithgroup/congroup_gamma0.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def is_Gamma0(x):
"""
return isinstance(x, Gamma0_class)


_gamma0_cache = {}
def Gamma0_constructor(N):
"""
Expand Down
1 change: 1 addition & 0 deletions src/sage/modular/modform/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def canonical_parameters(group, level, weight, base_ring):
# forms spaces.
return level, group, weight, base_ring


_cache = {}

def ModularForms_clear_cache():
Expand Down
1 change: 1 addition & 0 deletions src/sage/modular/pollack_stevens/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def create_object(self, version, key):
"""
return Symk_class(*key)


OverconvergentDistributions = OverconvergentDistributions_factory('OverconvergentDistributions')
Symk = Symk_factory('Symk')

Expand Down
1 change: 1 addition & 0 deletions src/sage/modular/pollack_stevens/fund_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def M2Z(x):
x.set_immutable()
return x


Id = M2Z([1, 0, 0, 1])
sig = M2Z([0, 1, -1, 0])
tau = M2Z([0, -1, 1, -1])
Expand Down
1 change: 1 addition & 0 deletions src/sage/modular/pollack_stevens/sigma0.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def create_object(self, version, key):
"""
return Sigma0_class(*key)


Sigma0 = Sigma0_factory('sage.modular.pollack_stevens.sigma0.Sigma0')


Expand Down
1 change: 1 addition & 0 deletions src/sage/modular/pollack_stevens/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def create_object(self, version, key):
"""
return PollackStevensModularSymbolspace(*key)


PollackStevensModularSymbols = PollackStevensModularSymbols_factory('PollackStevensModularSymbols')


Expand Down
1 change: 1 addition & 0 deletions src/sage/modules/fg_pid/fgp_morphism.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,7 @@ def lift(self, x):
assert self(y) == x, "bug in phi.lift()"
return y


from sage.categories.homset import Homset

import sage.misc.weak_dict
Expand Down
1 change: 1 addition & 0 deletions src/sage/plot/plot3d/plot3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@ def smooth_triangle(self, a, b, c, da, db, dc, color=None):
"""
return [a,b,c]


from . import parametric_plot3d
def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds):
"""
Expand Down
2 changes: 2 additions & 0 deletions src/sage/schemes/elliptic_curves/cm.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ def cm_orders(h, proof=None):
# quadratic field with class number h, and n is the number of such
# fields. These are all *unconditional* (not dependent on GRH).


watkins_table = {1: (163, 9), 2: (427, 18), 3: (907, 16), 4: (1555, 54), 5: (2683, 25),
6: (3763, 51), 7: (5923, 31), 8: (6307, 131), 9: (10627, 34), 10:
(13843, 87), 11: (15667, 41), 12: (17803, 206), 13: (20563, 37), 14:
Expand Down Expand Up @@ -717,6 +718,7 @@ class number `h` is also the largest discriminant, but this is not
# initialise it with h=1 only; other values will be added by calls to
# discriminants_with_bounded_class_number().


hDf_dict = {ZZ(1): [(ZZ(D), ZZ(h)) for D,h in
[(-3, 1), (-3, 2), (-3, 3), (-4, 1), (-4, 2), (-7, 1), (-7, 2),
(-8, 1), (-11, 1), (-19, 1), (-43, 1), (-67, 1), (-163, 1)]]}
Expand Down
2 changes: 2 additions & 0 deletions src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def _isogeny_determine_algorithm(E, kernel):

raise ValueError("invalid parameters to EllipticCurveIsogeny constructor")


from sage.misc.superseded import deprecated_function_alias
isogeny_determine_algorithm = deprecated_function_alias(33619, _isogeny_determine_algorithm)

Expand Down Expand Up @@ -3451,6 +3452,7 @@ def compute_isogeny_stark(E1, E2, ell):
qn /= qn.leading_coefficient()
return qn


from sage.misc.superseded import deprecated_function_alias
compute_isogeny_starks = deprecated_function_alias(34871, compute_isogeny_stark)

Expand Down
1 change: 1 addition & 0 deletions src/sage/schemes/elliptic_curves/ell_finite_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,7 @@ def curves_with_j_0_char3(K):

# dict to hold precomputed coefficient vectors of supersingular j values (excluding 0, 1728):


supersingular_j_polynomials = {}

def fill_ss_j_dict():
Expand Down
1 change: 1 addition & 0 deletions src/sage_docbuild/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,5 +498,6 @@ def excepthook(*exc_info):
builder = getattr(get_builder(name), typ)
builder()


if __name__ == '__main__':
sys.exit(main())
3 changes: 3 additions & 0 deletions src/sage_docbuild/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,7 @@ def add_page_context(app, pagename, templatename, context, doctree):
context['reference_root'] = os.path.join(relpath, 'index.html')
context['refsub'] = True


dangling_debug = False

def debug_inf(app, message):
Expand Down Expand Up @@ -816,6 +817,7 @@ def find_sage_dangling_links(app, env, node, contnode):
newnode.append(contnode)
return newnode


# lists of basic Python class which are documented as functions
base_class_as_func = [
'bool', 'complex', 'dict', 'file', 'float',
Expand All @@ -842,6 +844,7 @@ def nitpick_patch_config(app):
app.config.values['nitpicky'] = (False, 'sage')
app.config.values['nitpick_ignore'] = ([], 'sage')


skip_picklability_check_modules = [
#'sage.misc.test_nested_class', # for test only
'sage.misc.latex',
Expand Down
1 change: 1 addition & 0 deletions src/sage_docbuild/ext/sage_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def getdoc(obj, *args, **kwargs):
return sage_getdoc_original(obj)
# ------------------------------------------------------------------


if TYPE_CHECKING:
from sphinx.ext.autodoc.directive import DocumenterBridge

Expand Down
5 changes: 5 additions & 0 deletions src/sage_setup/autogen/interpreters/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ class StorageTypeSimple(StorageTypeAssignable):
"""
pass


ty_int = StorageTypeSimple('int')
ty_double = StorageTypeSimple('double')

Expand All @@ -461,6 +462,7 @@ def assign_c_from_py(self, c, py):
"""
return je("{{ c }} = CDE_to_dz({{ py }})", c=c, py=py)


ty_double_complex = StorageTypeDoubleComplex('double_complex')


Expand Down Expand Up @@ -650,6 +652,7 @@ def cython_clear(self, loc):
"""
return je("Py_CLEAR({{ loc }})", loc=loc)


ty_python = StorageTypePython()


Expand Down Expand Up @@ -846,6 +849,7 @@ def assign_c_from_py(self, c, py):
mpfr_set({{ c }}, rn.value, MPFR_RNDN)"""),
myself=self, c=c, py=py)


ty_mpfr = StorageTypeMPFR()

class StorageTypeMPC(StorageTypeAutoReference):
Expand Down Expand Up @@ -948,4 +952,5 @@ def assign_c_from_py(self, c, py):
cn{{ myself.id }} = self.domain({{ py }})
mpc_set_fr_fr({{ c }}, cn.__re, cn.__im, MPC_RNDNN)""", myself=self, c=c, py=py)


ty_mpc = StorageTypeMPC()
5 changes: 3 additions & 2 deletions src/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ description =
# E111: indentation is not a multiple of four
# E211: whitespace before '('
# E271: multiple spaces after keyword
# E305: expected 2 blank lines after class or function definition, found 1
# E306: expected 1 blank line before a nested definition, found 0
# E401: multiple imports on one line
# E502 the backslash is redundant between brackets
Expand All @@ -126,8 +127,8 @@ description =
# W605: invalid escape sequence ‘x’
# See https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
deps = pycodestyle
commands = pycodestyle --select E111,E21,E222,E227,E25,E271,E303,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/}
pycodestyle --select E111,E271,E301,E306,E401,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/}
commands = pycodestyle --select E111,E21,E222,E227,E25,E271,E303,E305,E306,E401,E502,E701,E702,E703,E71,E72,W291,W293,W391,W605 {posargs:{toxinidir}/sage/}
pycodestyle --select E111,E271,E301,E306,E401,E502,E703,E712,E713,E714,E72,W29,W391,W605, --filename *.pyx {posargs:{toxinidir}/sage/}
[pycodestyle]
max-line-length = 160
Expand Down

0 comments on commit 8137704

Please sign in to comment.