Skip to content

Commit 3c260c3

Browse files
author
Release Manager
committed
sagemathgh-39384: fixing PLW0120
this is about wrong use of `else` in `for` loops without `break` ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39384 Reported by: Frédéric Chapoton Reviewer(s): Vincent Macri
2 parents d64128d + 0a94fbb commit 3c260c3

File tree

12 files changed

+21
-35
lines changed

12 files changed

+21
-35
lines changed

build/pkgs/configure/checksums.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
tarball=configure-VERSION.tar.gz
2-
sha1=86711d4cbef2cd4e7bb4afcde36965e5dea908e0
3-
sha256=9793cf92ebdceb09050a585294de93c242c033745a0012cae1bd301d307a45df
2+
sha1=387f1f8a4e140c698a75c7c53756963ab76e00a6
3+
sha256=e932cd379d5d2d6629d02166db86f31d6737ff0ceaaf434c630b1984156b9124
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
efc0914cd8d72a9bdfdcca4511b55e290b9b6674
1+
bebda5eff2b63b6014245209827b13bf7a323631

src/sage/combinat/diagram_algebras.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -4802,8 +4802,7 @@ def insert_pairing(cur, intervals):
48024802
else:
48034803
level.append(cur)
48044804
return # We have stopped
4805-
else:
4806-
intervals.append([cur])
4805+
intervals.append([cur])
48074806
# Build a set of intervals that defines where to draw the diagram
48084807
intervals = [[]]
48094808
propogating = []

src/sage/combinat/regular_sequence.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1882,8 +1882,7 @@ def some_inverse_U_matrix(lines):
18821882
return U.inverse(), m_indices
18831883
except ZeroDivisionError:
18841884
pass
1885-
else:
1886-
raise RuntimeError('no invertible submatrix found')
1885+
raise RuntimeError('no invertible submatrix found')
18871886

18881887
def linear_combination_candidate(t_L, r_L, lines):
18891888
r"""

src/sage/combinat/words/finite_word.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -2367,8 +2367,7 @@ def longest_common_suffix(self, other):
23672367
for i, (b, c) in iter:
23682368
if b != c:
23692369
return self[-i:]
2370-
else:
2371-
return self[-i-1:]
2370+
return self[-i-1:]
23722371

23732372
def is_palindrome(self, f=None):
23742373
r"""
@@ -3739,8 +3738,7 @@ def is_subword_of(self, other):
37393738
for e in other:
37403739
if s == e:
37413740
s = next(its)
3742-
else:
3743-
return False
3741+
return False
37443742
except StopIteration:
37453743
return True
37463744

@@ -3881,8 +3879,7 @@ def is_lyndon(self) -> bool:
38813879
else:
38823880
# we found the first word in the lyndon factorization;
38833881
return False
3884-
else:
3885-
return i == 0
3882+
return i == 0
38863883

38873884
def lyndon_factorization(self):
38883885
r"""

src/sage/combinat/words/morphic.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ def __iter__(self):
344344
try:
345345
for a in self._morphism.image(next(w)):
346346
yield self._coding[a]
347-
else:
348-
next_w = next(w)
349-
w = chain([next_w], w, self._morphism.image(next_w))
347+
next_w = next(w)
348+
w = chain([next_w], w, self._morphism.image(next_w))
350349
except StopIteration:
351350
return

src/sage/combinat/words/morphism.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1550,8 +1550,7 @@ def _check_primitive(self):
15501550
for image in self.images():
15511551
if not dom_alphabet <= set(image):
15521552
return False
1553-
else:
1554-
return True
1553+
return True
15551554

15561555
def is_primitive(self):
15571556
r"""

src/sage/combinat/words/word_generators.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,7 @@ def _FibonacciWord_RecursiveConstructionIterator(self, alphabet=(0, 1)):
612612
for i in it:
613613
n += 1
614614
yield alphabet[i]
615-
else:
616-
Fib1, Fib0 = Fib1 + Fib0, Fib1
615+
Fib1, Fib0 = Fib1 + Fib0, Fib1
617616

618617
def FixedPointOfMorphism(self, morphism, first_letter):
619618
r"""
@@ -962,8 +961,7 @@ def _CharacteristicSturmianWord_LetterIterator(self, cf, alphabet=(0, 1)):
962961
for i in s1[n:]:
963962
n += 1
964963
yield alphabet[i]
965-
else:
966-
s1, s0 = s1*next(cf) + s0, s1
964+
s1, s0 = s1*next(cf) + s0, s1
967965
except StopIteration:
968966
return
969967

@@ -1306,8 +1304,7 @@ def _StandardEpisturmianWord_LetterIterator(self, directive_word):
13061304
for x in w[n:]:
13071305
n += 1
13081306
yield x
1309-
else:
1310-
w = W(w * W(next(d))).palindromic_closure()
1307+
w = W(w * W(next(d))).palindromic_closure()
13111308

13121309
def MinimalSmoothPrefix(self, n):
13131310
r"""

src/sage/modular/modform/element.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2502,9 +2502,8 @@ def minimal_twist(self, p=None):
25022502
h, tau = g.minimal_twist(p=None)
25032503
M = chi.modulus().lcm(tau.modulus())
25042504
return (h, chi.extend(M)*tau.extend(M))
2505-
else:
2506-
# f locally minimal at all p, hence globally minimal
2507-
return (self, DirichletGroup(1, self.base_ring())(1))
2505+
# f locally minimal at all p, hence globally minimal
2506+
return (self, DirichletGroup(1, self.base_ring())(1))
25082507

25092508
p = ZZ(p)
25102509
N = self.level()

src/sage/rings/polynomial/binary_form_reduce.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,9 @@ def covariant_z0(F, z0_cov=False, prec=53, emb=None, error_limit=0.000001):
232232
z = v0[1].constant_coefficient() + v0[0].constant_coefficient()*CF.gen(0)
233233
err = z.diameter() # precision
234234
zz = (w - z).abs().lower() # difference in w and z
235-
else:
236-
# despite there is no break, this happens
237-
if err > error_limit or err.is_NaN():
238-
raise ValueError("accuracy of Newton's root not within tolerance(%s > %s), increase precision" % (err, error_limit))
235+
# despite there is no break, this happens
236+
if err > error_limit or err.is_NaN():
237+
raise ValueError("accuracy of Newton's root not within tolerance(%s > %s), increase precision" % (err, error_limit))
239238
if z.imag().upper() <= z.diameter():
240239
raise ArithmeticError("Newton's method converged to z not in the upper half plane")
241240
z = z.center()

src/sage/schemes/elliptic_curves/hom.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,7 @@ def compare_via_evaluation(left, right):
11991199
if P._has_order_at_least(4*d + 1, attempts=50):
12001200
# if P.height(precision=250) == 0: # slow sometimes
12011201
return left._eval(P) == right._eval(P)
1202-
else:
1203-
assert False, "couldn't find a point of large enough order"
1202+
assert False, "couldn't find a point of large enough order"
12041203

12051204
else:
12061205
raise NotImplementedError('not implemented for this base field')

src/sage/schemes/elliptic_curves/hom_velusqrt.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,7 @@ def _point_outside_subgroup(P):
581581
Q = E.random_point()
582582
if n*Q or not P.weil_pairing(Q,n).is_one():
583583
return Q
584-
else:
585-
raise NotImplementedError('could not find a point outside the kernel')
584+
raise NotImplementedError('could not find a point outside the kernel')
586585

587586

588587
class EllipticCurveHom_velusqrt(EllipticCurveHom):

0 commit comments

Comments
 (0)