From 7b0e9661900c40fdb2135afdf374c3b6ab9421b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 8 Oct 2024 20:06:24 +0200 Subject: [PATCH 1/2] using ruff to fix more E713 --- .github/sync_labels.py | 4 ++-- src/sage/coding/gabidulin_code.py | 2 +- .../arithmetic_dynamics/endPN_minimal_model.py | 2 +- .../dynamics/arithmetic_dynamics/projective_ds.py | 12 ++++++------ src/sage/functions/bessel.py | 2 +- src/sage/games/hexad.py | 6 +++--- src/sage/geometry/hyperplane_arrangement/plot.py | 6 +++--- src/sage/geometry/polyhedron/base5.py | 2 +- src/sage/graphs/digraph_generators.py | 2 +- src/sage/graphs/generators/classical_geometries.py | 2 +- src/sage/graphs/generic_graph.py | 4 ++-- src/sage/graphs/graph_latex.py | 2 +- src/sage/graphs/orientations.py | 4 ++-- src/sage/interfaces/maxima_lib.py | 2 +- src/sage/knots/knotinfo.py | 4 ++-- src/sage/knots/link.py | 4 ++-- src/sage/manifolds/point.py | 2 +- src/sage/quadratic_forms/genera/genus.py | 9 +++++---- src/sage/repl/rich_output/display_manager.py | 4 ++-- src/sage/rings/function_field/order_basis.py | 6 +++--- src/sage/rings/function_field/order_polymod.py | 2 +- src/sage/rings/function_field/order_rational.py | 2 +- src/sage/rings/number_field/number_field_ideal.py | 2 +- src/sage/rings/number_field/order.py | 4 ++-- src/sage/rings/pari_ring.py | 2 +- src/sage/rings/polynomial/pbori/ll.py | 2 +- src/sage/rings/valuation/augmented_valuation.py | 4 ++-- src/sage/rings/valuation/inductive_valuation.py | 2 +- src/sage/schemes/curves/affine_curve.py | 6 +++--- src/sage/schemes/curves/projective_curve.py | 12 ++++++------ src/sage/schemes/curves/zariski_vankampen.py | 6 +++--- src/sage/symbolic/callable.py | 4 ++-- src/sage/topology/simplicial_complex.py | 2 +- 33 files changed, 66 insertions(+), 65 deletions(-) diff --git a/.github/sync_labels.py b/.github/sync_labels.py index dbd8566c517..751a81543e8 100755 --- a/.github/sync_labels.py +++ b/.github/sync_labels.py @@ -609,7 +609,7 @@ def actor_valid(self): for com in coms: for auth in com['authors']: login = auth['login'] - if not login in authors: + if login not in authors: if not self.is_this_bot(login) and login != author: debug('PR %s has recent commit by %s' % (self._issue, login)) authors.append(login) @@ -746,7 +746,7 @@ def add_label(self, label): r""" Add the given label to the issue or PR. """ - if not label in self.get_labels(): + if label not in self.get_labels(): self.edit(label, '--add-label') info('Add label to %s: %s' % (self._issue, label)) diff --git a/src/sage/coding/gabidulin_code.py b/src/sage/coding/gabidulin_code.py index cce8fcfc7d5..3db66e4af7b 100644 --- a/src/sage/coding/gabidulin_code.py +++ b/src/sage/coding/gabidulin_code.py @@ -207,7 +207,7 @@ def __init__(self, base_field, length, dimension, sub_field=None, if not len(evaluation_points) == length: raise ValueError("the number of evaluation points should be equal to the length of the code") for i in range(length): - if not evaluation_points[i] in base_field: + if evaluation_points[i] not in base_field: raise ValueError("evaluation point does not belong to the 'base field'") basis = self.matrix_form_of_vector(vector(evaluation_points)) if basis.rank() != length: diff --git a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py index f6ffb67d832..c8528c4821f 100644 --- a/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py +++ b/src/sage/dynamics/arithmetic_dynamics/endPN_minimal_model.py @@ -590,7 +590,7 @@ def BM_all_minimal(vp, return_transformation=False, D=None): for M in all_M: new_map = mp.conjugate(M) new_map.normalize_coordinates() - if not [new_map, M] in all_maps: + if [new_map, M] not in all_maps: all_maps.append([new_map, M]) #Split into conjugacy classes diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py index 262c063a35d..a74efd9129a 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py @@ -2935,7 +2935,7 @@ def parallel_function(morphism): # Calling possible_periods for each prime in parallel parallel_data = [] for q in primes(primebound[0], primebound[1] + 1): - if not (q in badprimes): + if q not in badprimes: F = self.change_ring(GF(q)) parallel_data.append(((F,), {})) @@ -6768,7 +6768,7 @@ def is_Lattes(self): (crit_set, post_crit_set) = crit, list(post_crit) # All Lattes maps have 3 or 4 post critical values - if not len(post_crit_set) in [3, 4]: + if len(post_crit_set) not in [3, 4]: return False f = F_crit.dehomogenize(1)[0] @@ -7228,7 +7228,7 @@ def lift_to_rational_periodic(self, points_modp, B=None): while not done and k <= n: newP = self(newP) if newP == P: - if not ([P, k] in good_points): + if [P, k] not in good_points: good_points.append([newP, k]) done = True k += 1 @@ -7499,7 +7499,7 @@ def all_periodic_points(self, **kwds): pos_points = [] # check period, remove duplicates for i in range(len(all_points)): - if all_points[i][1] in periods and not (all_points[i] in pos_points): + if all_points[i][1] in periods and all_points[i] not in pos_points: pos_points.append(all_points[i]) periodic_points = DS.lift_to_rational_periodic(pos_points,B) for p,n in periodic_points: @@ -7594,7 +7594,7 @@ def all_rational_preimages(self, points): P = points.pop() preimages = self.rational_preimages(P) for i in range(len(preimages)): - if not preimages[i] in preperiodic: + if preimages[i] not in preperiodic: points.append(preimages[i]) preperiodic.add(preimages[i]) return list(preperiodic) @@ -9073,7 +9073,7 @@ def is_newton(self, return_conjugation=False): """ if self.degree() == 1: raise NotImplementedError("degree one Newton maps are trivial") - if not self.base_ring() in NumberFields(): + if self.base_ring() not in NumberFields(): raise NotImplementedError("only implemented over number fields") # check if Newton map sigma_1 = self.sigma_invariants(1) diff --git a/src/sage/functions/bessel.py b/src/sage/functions/bessel.py index 2eced09d619..1cd132b3a45 100644 --- a/src/sage/functions/bessel.py +++ b/src/sage/functions/bessel.py @@ -1228,7 +1228,7 @@ def Bessel(*args, **kwds): _type = kwds['typ'] else: _type = 'J' - if not (_type in ['I', 'J', 'K', 'Y']): + if _type not in ['I', 'J', 'K', 'Y']: raise ValueError("type must be one of I, J, K, Y") # return the function diff --git a/src/sage/games/hexad.py b/src/sage/games/hexad.py index 5d3e2785900..6a8b5e178e5 100644 --- a/src/sage/games/hexad.py +++ b/src/sage/games/hexad.py @@ -466,15 +466,15 @@ def find_hexad3(self, pts, x0, x1): L = set(pts) H = {x0, x1} for i in range(18): - if (not (MINIMOG[0][2] in H) and L <= picture_set(self.picture21, self.square[i])): + if (MINIMOG[0][2] not in H and L <= picture_set(self.picture21, self.square[i])): WHAT = ["square " + str(i), "picture " + str(MINIMOG[0][2])] H = H | picture_set(self.picture21, self.square[i]) return list(H), WHAT - if (not (MINIMOG[2][1] in H) and L <= picture_set(self.picture02, self.square[i])): + if (MINIMOG[2][1] not in H and L <= picture_set(self.picture02, self.square[i])): WHAT = ["square " + str(i), "picture " + str(MINIMOG[2][1])] H = H | picture_set(self.picture02, self.square[i]) return list(H), WHAT - if (not (MINIMOG[0][0] in H) and L <= picture_set(self.picture00, self.square[i])): + if (MINIMOG[0][0] not in H and L <= picture_set(self.picture00, self.square[i])): WHAT = ["square " + str(i), "picture " + str(MINIMOG[0][0])] H = H | picture_set(self.picture00, self.square[i]) return list(H), WHAT diff --git a/src/sage/geometry/hyperplane_arrangement/plot.py b/src/sage/geometry/hyperplane_arrangement/plot.py index 190bef9982f..7e550bfd472 100644 --- a/src/sage/geometry/hyperplane_arrangement/plot.py +++ b/src/sage/geometry/hyperplane_arrangement/plot.py @@ -212,14 +212,14 @@ def plot(hyperplane_arrangement, **kwds): if 'ranges' in kwds: ranges_set = True ranges = kwds.pop('ranges') - if not type(ranges) in [list,tuple]: # ranges is a single number + if type(ranges) not in [list,tuple]: # ranges is a single number ranges = [ranges] * N # So ranges is some type of list. elif dim == 2: # arrangement of lines in the plane - if not type(ranges[0]) in [list,tuple]: # a single interval + if type(ranges[0]) not in [list,tuple]: # a single interval ranges = [ranges] * N elif dim == 3: # arrangement of planes in 3-space - if not type(ranges[0][0]) in [list,tuple]: + if type(ranges[0][0]) not in [list,tuple]: ranges = [ranges] * N elif dim not in [2,3]: # ranges is not an option unless dim is 2 or 3 ranges_set = False diff --git a/src/sage/geometry/polyhedron/base5.py b/src/sage/geometry/polyhedron/base5.py index d683955b53a..21a463f1234 100644 --- a/src/sage/geometry/polyhedron/base5.py +++ b/src/sage/geometry/polyhedron/base5.py @@ -2452,7 +2452,7 @@ def _test_lawrence(self, tester=None, **options): if tester is None: tester = self._tester(**options) - if self.backend() == 'normaliz' and not self.base_ring() in (ZZ, QQ): + if self.backend() == 'normaliz' and self.base_ring() not in (ZZ, QQ): # Speeds up the doctest for significantly. self = self.change_ring(self._internal_base_ring) diff --git a/src/sage/graphs/digraph_generators.py b/src/sage/graphs/digraph_generators.py index ed0c5c82c81..b374392163e 100644 --- a/src/sage/graphs/digraph_generators.py +++ b/src/sage/graphs/digraph_generators.py @@ -1657,7 +1657,7 @@ def RandomDirectedGNM(self, n, m, loops=False): if is_dense: for u in range(n): for v in range(n): - if ((u != v) or loops) and (not (v in adj[u])): + if ((u != v) or loops) and (v not in adj[u]): D.add_edge(u, v) return D diff --git a/src/sage/graphs/generators/classical_geometries.py b/src/sage/graphs/generators/classical_geometries.py index f5dbad17169..8cd60e5862e 100644 --- a/src/sage/graphs/generators/classical_geometries.py +++ b/src/sage/graphs/generators/classical_geometries.py @@ -1107,7 +1107,7 @@ def T2starGeneralizedQuadrangleGraph(q, dual=False, hyperoval=None, field=None, raise RuntimeError("incorrect hyperoval size") for L in Theta.blocks(): if set(L).issubset(Pi): - if not len(HO.intersection(L)) in [0, 2]: + if len(HO.intersection(L)) not in [0, 2]: raise RuntimeError("incorrect hyperoval") L = [[y for y in z if y not in HO] diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index c55dfc08f92..a86e936022e 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -18926,7 +18926,7 @@ def breadth_first_search(self, start, ignore_direction=False, # Non-existing start vertex is detected later if distance > 0. if not distance: for v in queue: - if not v[0] in self: + if v[0] not in self: raise LookupError("start vertex ({0}) is not a vertex of the graph".format(v[0])) for v, d in queue: @@ -22676,7 +22676,7 @@ def graphviz_string(self, **options): for f in edge_option_functions: edge_options.update(f((u, v, label))) - if not edge_options['edge_string'] in ['--', '->']: + if edge_options['edge_string'] not in ['--', '->']: raise ValueError("edge_string(='{}') in edge_options dict for " "the edge ({}, {}) should be '--' or '->'" .format(edge_options['edge_string'], u, v)) diff --git a/src/sage/graphs/graph_latex.py b/src/sage/graphs/graph_latex.py index 4606c56b4f9..a008b6f6718 100644 --- a/src/sage/graphs/graph_latex.py +++ b/src/sage/graphs/graph_latex.py @@ -1170,7 +1170,7 @@ def set_option(self, option_name, option_value=None): raise TypeError('%s option must be a dictionary, not %s' % (name, value)) else: for key, x in value.items(): - if not type(x) in [int, Integer, float, RealLiteral] or not x >= 0.0: + if type(x) not in [int, Integer, float, RealLiteral] or not x >= 0.0: raise ValueError('%s option for %s needs to be a positive number, not %s' % (name, key, x)) elif name in boolean_dicts: if not isinstance(value, dict): diff --git a/src/sage/graphs/orientations.py b/src/sage/graphs/orientations.py index 2dac79b7146..e9be5ea0b29 100644 --- a/src/sage/graphs/orientations.py +++ b/src/sage/graphs/orientations.py @@ -467,7 +467,7 @@ def _strong_orientations_of_a_mixed_graph(Dg, V, E): while i < length: u, v = E[i] Dg.delete_edge(u, v) - if not (v in Dg.depth_first_search(u)): + if v not in Dg.depth_first_search(u): # del E[i] in constant time E[i] = E[-1] E.pop() @@ -478,7 +478,7 @@ def _strong_orientations_of_a_mixed_graph(Dg, V, E): else: Dg.add_edge(u, v) Dg.delete_edge(v, u) - if not (u in Dg.depth_first_search(v)): + if u not in Dg.depth_first_search(v): # del E[i] in constant time E[i] = E[-1] E.pop() diff --git a/src/sage/interfaces/maxima_lib.py b/src/sage/interfaces/maxima_lib.py index 1e6f85cfae0..499b2565236 100644 --- a/src/sage/interfaces/maxima_lib.py +++ b/src/sage/interfaces/maxima_lib.py @@ -1657,7 +1657,7 @@ def sr_to_max(expr): return EclObject(special_sage_to_max[op](*[sr_to_max(o) for o in expr.operands()])) elif op == tuple: return EclObject(([mlist], list(sr_to_max(op) for op in expr.operands()))) - elif not (op in sage_op_dict): + elif op not in sage_op_dict: # Maxima does some simplifications automatically by default # so calling maxima(expr) can change the structure of expr # op_max=caar(maxima(expr).ecl()) diff --git a/src/sage/knots/knotinfo.py b/src/sage/knots/knotinfo.py index 6001f7abeff..235ba1fddef 100644 --- a/src/sage/knots/knotinfo.py +++ b/src/sage/knots/knotinfo.py @@ -2658,7 +2658,7 @@ def __getitem__(self, item): [, , ] """ from sage.rings.integer import Integer - if not type(item) in (int, Integer): + if type(item) not in (int, Integer): raise ValueError('item must be an integer') l = self.list() max_item = len(l) @@ -2701,7 +2701,7 @@ def __call__(self, item): return self[item] from sage.rings.integer import Integer - if not type(item) in (int, Integer): + if type(item) not in (int, Integer): raise ValueError('item must be an integer') l = self.list() max_item = len(l) + 1 diff --git a/src/sage/knots/link.py b/src/sage/knots/link.py index dbaca5662c8..fdcc9fc00ab 100644 --- a/src/sage/knots/link.py +++ b/src/sage/knots/link.py @@ -1201,7 +1201,7 @@ def _khovanov_homology_cached(self, height, ring=ZZ): else: m = matrix(ring, len(bases[(i,j)]), 0) complexes[i] = m.transpose() - if not (i-1, j) in bases: + if (i-1, j) not in bases: complexes[i-1] = matrix(ring, len(bases[(i,j)]), 0) homologies = ChainComplex(complexes).homology() return tuple(sorted(homologies.items())) @@ -2313,7 +2313,7 @@ def seifert_circles(self): while a not in par: par.append(a) posnext = C[(C.index(a) - 1) % 4] - if tails[posnext] == C and not [posnext] in result: + if tails[posnext] == C and [posnext] not in result: a = posnext else: a = C[(C.index(a) + 1) % 4] diff --git a/src/sage/manifolds/point.py b/src/sage/manifolds/point.py index 3971a85c776..f50ae75f553 100644 --- a/src/sage/manifolds/point.py +++ b/src/sage/manifolds/point.py @@ -689,7 +689,7 @@ def __eq__(self, other): diff = xs - xo period = periods[ind] if period is not None: - if not (diff/period in ZZ): + if diff/period not in ZZ: return False else: if isinstance(diff, Expression) and not diff.is_trivial_zero(): diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py index 62b5c98f90b..0227fa8319a 100644 --- a/src/sage/quadratic_forms/genera/genus.py +++ b/src/sage/quadratic_forms/genera/genus.py @@ -509,12 +509,12 @@ def is_2_adic_genus(genus_symbol_quintuple_list) -> bool: return False if s[1] == 2 and s[3] == 1: if s[2] % 8 in (1, 7): - if not s[4] in (0, 2, 6): + if s[4] not in (0, 2, 6): return False if s[2] % 8 in (3, 5): - if not s[4] in (2, 4, 6): + if s[4] not in (2, 4, 6): return False - if (s[1] - s[4]) % 2 == 1: + if (s[1] - s[4]) % 2: return False if s[3] == 0 and s[4] != 0: return False @@ -2802,7 +2802,8 @@ def direct_sum(self, other): signature_pair = (p1 + p2, n1 + n2) primes = [s.prime() for s in self.local_symbols()] - primes += [s.prime() for s in other.local_symbols() if not s.prime() in primes] + primes.extend(s.prime() for s in other.local_symbols() + if s.prime() not in primes) primes.sort() local_symbols = [] for p in primes: diff --git a/src/sage/repl/rich_output/display_manager.py b/src/sage/repl/rich_output/display_manager.py index 473e860ba42..31bc1db3ffd 100644 --- a/src/sage/repl/rich_output/display_manager.py +++ b/src/sage/repl/rich_output/display_manager.py @@ -634,10 +634,10 @@ def _rich_output_formatter(self, obj, rich_repr_kwds): rich_output = self._promote_output(rich_output) # check that the output container types are valid for the backend supported = self._backend.supported_output() - if not (type(plain_text) in supported): + if type(plain_text) not in supported: raise OutputTypeException( 'text output container not supported: {0}'.format(type(plain_text))) - if not (type(rich_output) in supported): + if type(rich_output) not in supported: raise OutputTypeException( 'output container not supported: {0}'.format(type(rich_output))) return plain_text, rich_output diff --git a/src/sage/rings/function_field/order_basis.py b/src/sage/rings/function_field/order_basis.py index e4fa3dfe39e..1cf89e3f966 100644 --- a/src/sage/rings/function_field/order_basis.py +++ b/src/sage/rings/function_field/order_basis.py @@ -102,7 +102,7 @@ def __init__(self, basis, check=True): if check: if self._module.rank() != field.degree(): raise ValueError("basis {} is not linearly independent".format(basis)) - if not to_V(field(1)) in self._module: + if to_V(field(1)) not in self._module: raise ValueError("the identity element must be in the module spanned by basis {}".format(basis)) if not all(to_V(a*b) in self._module for a in basis for b in basis): raise ValueError("the module generated by basis {} must be closed under multiplication".format(basis)) @@ -399,7 +399,7 @@ def __init__(self, basis, check=True): if check: if self._module.rank() != field.degree(): raise ValueError("basis {} is not linearly independent".format(basis)) - if not W.coordinate_vector(to(field(1))) in self._module: + if W.coordinate_vector(to(field(1))) not in self._module: raise ValueError("the identity element must be in the module spanned by basis {}".format(basis)) if not all(W.coordinate_vector(to(a*b)) in self._module for a in basis for b in basis): raise ValueError("the module generated by basis {} must be closed under multiplication".format(basis)) @@ -431,7 +431,7 @@ def _element_constructor_(self, f): V, fr_V, to_V = F.vector_space() W = self._ambient_space - if not W.coordinate_vector(to_V(f)) in self._module: + if W.coordinate_vector(to_V(f)) not in self._module: raise TypeError("{} is not an element of {}".format(f, self)) return f diff --git a/src/sage/rings/function_field/order_polymod.py b/src/sage/rings/function_field/order_polymod.py index 2ebb062a432..16ff2d8f2ae 100644 --- a/src/sage/rings/function_field/order_polymod.py +++ b/src/sage/rings/function_field/order_polymod.py @@ -888,7 +888,7 @@ def ideal(self, *gens): """ if len(gens) == 1: gens = gens[0] - if not type(gens) in (list,tuple): + if type(gens) not in (list,tuple): gens = (gens,) mgens = [g * b for g in gens for b in self._basis] return self.ideal_with_gens_over_base(mgens) diff --git a/src/sage/rings/function_field/order_rational.py b/src/sage/rings/function_field/order_rational.py index 87cbbdb4858..d90124c6800 100644 --- a/src/sage/rings/function_field/order_rational.py +++ b/src/sage/rings/function_field/order_rational.py @@ -83,7 +83,7 @@ def _element_constructor_(self, f): except TypeError: raise TypeError("unable to convert to an element of {}".format(F)) - if not f.denominator() in self.function_field().constant_base_field(): + if f.denominator() not in self.function_field().constant_base_field(): raise TypeError("%r is not an element of %r" % (f,self)) return f diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py index d62ae34fb95..3686840ccba 100644 --- a/src/sage/rings/number_field/number_field_ideal.py +++ b/src/sage/rings/number_field/number_field_ideal.py @@ -2161,7 +2161,7 @@ def reduce(self, f): R = self.number_field().maximal_order() - if not (f in R): + if f not in R: raise TypeError("reduce only defined for integral elements") Rbasis = R.basis() diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py index e54d2f454af..55db3bbbcbf 100644 --- a/src/sage/rings/number_field/order.py +++ b/src/sage/rings/number_field/order.py @@ -894,7 +894,7 @@ def ring_generators(self): gens.append(g) n.append(g.absolute_minpoly().degree()) W = A.span([to_V(x) for x in monomials(gens, n)]) - remaining = [x for x in remaining if not to_V(x) in W] + remaining = [x for x in remaining if to_V(x) not in W] return Sequence(gens, immutable=True) @cached_method @@ -1590,7 +1590,7 @@ def _element_constructor_(self, x): if not isinstance(x, Element) or x.parent() is not self._K: x = self._K(x) V, _, embedding = self._K.vector_space() - if not embedding(x) in self._module_rep: + if embedding(x) not in self._module_rep: raise TypeError("Not an element of the order.") return self._element_type(self, x) diff --git a/src/sage/rings/pari_ring.py b/src/sage/rings/pari_ring.py index 61459d8d50d..b8f2b62d5a7 100644 --- a/src/sage/rings/pari_ring.py +++ b/src/sage/rings/pari_ring.py @@ -124,7 +124,7 @@ def __pow__(self, other): sage: a^2 9 """ - if not (other in PariRing()): + if other not in PariRing(): other = Pari(other) return self.__class__(self.__x ** other.__x, parent=_inst) diff --git a/src/sage/rings/polynomial/pbori/ll.py b/src/sage/rings/polynomial/pbori/ll.py index 5292050d6a7..9ec3a57bb4c 100644 --- a/src/sage/rings/polynomial/pbori/ll.py +++ b/src/sage/rings/polynomial/pbori/ll.py @@ -79,7 +79,7 @@ def eliminate(polys, on_the_fly=False, prot=False, reduction_function=None, lm = p.lex_lead() if lm.deg() == 1: - if not (lm in linear_leading_monomials): + if lm not in linear_leading_monomials: linear_leading_monomials.add(lm) linear_leads.append(p) else: diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py index ff35d1166e9..b9f0229f787 100644 --- a/src/sage/rings/valuation/augmented_valuation.py +++ b/src/sage/rings/valuation/augmented_valuation.py @@ -1390,7 +1390,7 @@ def lift(self, F, report_coefficients=False): F = self.residue_ring().coerce(F) from sage.categories.fields import Fields - if not self.domain().base_ring() in Fields(): + if self.domain().base_ring() not in Fields(): raise NotImplementedError("only implemented for polynomial rings over fields") if F.is_constant(): @@ -1481,7 +1481,7 @@ def lift_to_key(self, F, check=True): F = self.residue_ring().coerce(F) from sage.categories.fields import Fields - if not self.domain().base_ring() in Fields(): + if self.domain().base_ring() not in Fields(): raise NotImplementedError("only implemented for polynomial rings over fields") if check: diff --git a/src/sage/rings/valuation/inductive_valuation.py b/src/sage/rings/valuation/inductive_valuation.py index 9646cf5e429..470e4990bed 100644 --- a/src/sage/rings/valuation/inductive_valuation.py +++ b/src/sage/rings/valuation/inductive_valuation.py @@ -1375,7 +1375,7 @@ def minimal_representative(self, f): f = self.domain().coerce(f) from sage.categories.fields import Fields - if not self.domain().base_ring() in Fields(): + if self.domain().base_ring() not in Fields(): raise NotImplementedError("only implemented for polynomial rings over fields") if f.is_zero(): diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py index d98209bdba1..0b647c8411b 100755 --- a/src/sage/schemes/curves/affine_curve.py +++ b/src/sage/schemes/curves/affine_curve.py @@ -579,7 +579,7 @@ def multiplicity(self, P): TypeError: (=(1, 1)) is not a point on (=Affine Plane Curve over Rational Field defined by x^6 - x^3 + y^3) """ - if not self.base_ring() in Fields(): + if self.base_ring() not in Fields(): raise TypeError("curve must be defined over a field") # Check whether P is a point on this curve @@ -866,7 +866,7 @@ def __init__(self, A, X): """ super().__init__(A, X) - if not A.base_ring() in Fields(): + if A.base_ring() not in Fields(): raise TypeError("curve not defined over a field") d = super(Curve_generic, self).dimension() @@ -1320,7 +1320,7 @@ def blowup(self, P=None): self(P) except TypeError: raise TypeError("(=%s) must be a point on this curve" % P) - if not self.base_ring() in Fields(): + if self.base_ring() not in Fields(): raise TypeError("the base ring of this curve must be a field") if not self.is_irreducible(): raise TypeError("this curve must be irreducible") diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py index 7c8cf62c5ea..b21b6bbed91 100755 --- a/src/sage/schemes/curves/projective_curve.py +++ b/src/sage/schemes/curves/projective_curve.py @@ -1466,7 +1466,7 @@ def extension(self): # make sure the defining polynomial variable names are the same for K, N N = NumberField(K.defining_polynomial().parent()(F.defining_polynomial()), str(K.gen())) return N.composite_fields(K, both_maps=True)[0][1]*F.embeddings(N)[0] - if not self.base_ring() in NumberFields(): + if self.base_ring() not in NumberFields(): raise NotImplementedError("the base ring of this curve must be a number field") if not self.is_irreducible(): raise TypeError("this curve must be irreducible") @@ -1499,7 +1499,7 @@ def extension(self): try: temp_pt = (temp_qua*temp_exc)(temp_exc.domain()(pts[i])) pts.pop(i) - if not PP(list(temp_pt)) in [PP(list(tpt)) for tpt in pts]: + if PP(list(temp_pt)) not in [PP(list(tpt)) for tpt in pts]: pts.append(temp_pt) except (TypeError, ValueError): pass @@ -1519,7 +1519,7 @@ def extension(self): newpts = [PP(list(pt) + [0]) for pt in X.rational_points()] # avoid duplicates for pt in newpts: - if not PP(list(pt)) in [PP(list(tpt)) for tpt in pts]: + if PP(list(pt)) not in [PP(list(tpt)) for tpt in pts]: pts.append(pt) return phi @@ -1604,7 +1604,7 @@ def __init__(self, A, X, category=None): """ super().__init__(A, X, category=category) - if not A.base_ring() in Fields(): + if A.base_ring() not in Fields(): raise TypeError("curve not defined over a field") d = super(Curve_generic, self).dimension() @@ -2296,7 +2296,7 @@ def __init__(self, A, f): ideal = self.defining_ideal() gs = self.ambient_space().gens() for i in range(self.ngens()): - if not gs[i] in ideal: + if gs[i] not in ideal: self._open_affine = self.affine_patch(i) self._open_affine_index = i break @@ -2733,7 +2733,7 @@ def places_on(self, point): # determine the affine patch where the point lies S = prime.ring() for i in range(S.ngens()): - if not S.gen(i) in prime: + if S.gen(i) not in prime: break phi = self._map_to_function_field diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py index 925d1d9f2d0..f410a73f8fc 100755 --- a/src/sage/schemes/curves/zariski_vankampen.py +++ b/src/sage/schemes/curves/zariski_vankampen.py @@ -732,7 +732,7 @@ def roots_interval(f, x0): diam = min((CF(r) - CF(r0)).abs() for r0 in roots[:i] + roots[i + 1:]) / divisor envelop = IF(diam) * IF((-1, 1), (-1, 1)) - while not newton(fx, r, r + envelop) in r + envelop: + while newton(fx, r, r + envelop) not in r + envelop: prec += 53 IF = ComplexIntervalField(prec) CF = ComplexField(prec) @@ -1302,7 +1302,7 @@ def braid_monodromy(f, arrangement=(), vertical=False): g = f.parent()(prod(glist)) d = g.degree(y) if not arrangement_v: # change of coordinates only if indices_v is empty - while not g.coefficient(y**d) in F: + while g.coefficient(y**d) not in F: g = g.subs({x: x + y}) d = g.degree(y) arrangement_h = tuple(f1.subs({x: x + y}) for f1 in arrangement_h) @@ -1752,7 +1752,7 @@ def fundamental_group(f, simplified=True, projective=False, puiseux=True): x, y = g.parent().gens() F = g.parent().base_ring() d = g.degree(y) - while not g.coefficient(y**d) in F: + while g.coefficient(y**d) not in F: g = g.subs({x: x + y}) d = g.degree(y) if projective: diff --git a/src/sage/symbolic/callable.py b/src/sage/symbolic/callable.py index a8678861b91..3a7b7f553a6 100644 --- a/src/sage/symbolic/callable.py +++ b/src/sage/symbolic/callable.py @@ -213,11 +213,11 @@ def unify_arguments(self, x): temp = set() # Sorting remaining variables. for j in range(i, len(a)): - if not a[j] in temp: + if a[j] not in temp: temp.add(a[j]) for j in range(i, len(b)): - if not b[j] in temp: + if b[j] not in temp: temp.add(b[j]) new_list.extend(sorted(temp, key=repr)) diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index 241b56a0ff6..54166cf4f1f 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -3707,7 +3707,7 @@ def stellar_subdivision(self, simplex, inplace=False, is_mutable=True): if inplace and self._is_immutable: raise ValueError("this simplicial complex is not mutable") - if not Simplex(simplex) in self: + if Simplex(simplex) not in self: raise ValueError("the face to subdivide is not a face of self") if inplace: From 181e9603a39a3cb0202c53b805c09cd70368b4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Tue, 8 Oct 2024 20:08:41 +0200 Subject: [PATCH 2/2] activate ruff check for E713 --- src/tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/tox.ini b/src/tox.ini index 094c1f54806..c76a8b65c2d 100644 --- a/src/tox.ini +++ b/src/tox.ini @@ -291,7 +291,6 @@ passenv = RUFF_OUTPUT_FORMAT # 116 PLR0402 [*] Use `from matplotlib import cm` in lieu of alias # 111 PLW0603 [ ] Using the global statement to update `AA_0` is discouraged # 78 F841 [*] Local variable `B` is assigned to but never used -# 64 E713 [*] Test for membership should be `not in` # 48 PLW0602 [ ] Using global for `D` but no assignment is done # 33 PLR1711 [*] Useless `return` statement at end of function # 24 E714 [*] Test for object identity should be `is not` @@ -315,7 +314,7 @@ passenv = RUFF_OUTPUT_FORMAT # 1 F402 [ ] Import `factor` from line 259 shadowed by loop variable # 1 PLC0208 [*] Use a sequence type instead of a `set` when iterating over values # -commands = ruff check --ignore PLR2004,I001,F401,E741,F821,PLR0912,PLR0913,E402,PLR0915,PLW2901,PLR5501,PLR0911,E731,F405,PLR1714,PLR1736,F403,PLR0402,PLW0603,F841,E713,PLW0602,PLW0642,PLR1711,E714,SIM101,PLR1704,PLW3301,PLW1510,E721,PLW0211,PLW0120,F811,PLC2401,PLC0414,E743,PLE0101,PLR0124,PLW0127,F541,PLW1508,PLC3002,E742,PLE0302,PLW0129,F402,PLC0208 {posargs:{toxinidir}/sage/} +commands = ruff check --ignore PLR2004,I001,F401,E741,F821,PLR0912,PLR0913,E402,PLR0915,PLW2901,PLR5501,PLR0911,E731,F405,PLR1714,PLR1736,F403,PLR0402,PLW0603,F841,PLW0602,PLW0642,PLR1711,E714,SIM101,PLR1704,PLW3301,PLW1510,E721,PLW0211,PLW0120,F811,PLC2401,PLC0414,E743,PLE0101,PLR0124,PLW0127,F541,PLW1508,PLC3002,E742,PLE0302,PLW0129,F402,PLC0208 {posargs:{toxinidir}/sage/} [flake8] rst-roles =