Skip to content

Commit 5c75f51

Browse files
committed
fix E202
1 parent 88cc434 commit 5c75f51

File tree

6 files changed

+18
-23
lines changed

6 files changed

+18
-23
lines changed

pyproject.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ build-backend = "mesonpy"
4646
# and we ignore it to avoid needing additional indentation after
4747
# long logical statements.
4848
#
49-
# E202 whitespace before '}'
50-
# Reasoning: this rule flags up format strings f"{x = }". This is discussed
51-
# here: https://github.com/PyCQA/pycodestyle/issues/1201, as we
52-
# prefer printing whitespace around =, we disable this rule.
53-
#
5449
# E501 line too long (128 > 120 characters)
5550
# Reasoning: this is a work in progress and will be enforced once a line length
5651
# and refactor has taken place. See issue #214
@@ -63,7 +58,7 @@ build-backend = "mesonpy"
6358
# Reasoning: this is a work in progress and will be enforced after #210 is
6459
# resolved.
6560
max-line-length = 120
66-
ignore = ['E129','E202','E501','E741','E743']
61+
ignore = ['E129','E501','E741','E743']
6762
exclude = 'src/flint/flintlib/.*'
6863

6964
[tool.spin]

src/flint/test/test_all.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ def test_fmpz_mod_poly():
19211921
R_other = fmpz_mod_poly_ctx(F_other)
19221922

19231923
assert raises(lambda: fmpz_mod_poly(1, "A"), TypeError) # Need a valid context
1924-
assert raises(lambda: R(R_other([1,2,3])), ValueError), f"{R(R_other([1,2,3])) = }" # moduli must match
1924+
assert raises(lambda: R(R_other([1,2,3])), ValueError) # moduli must match
19251925
assert raises(lambda: R(F_other(2)), ValueError) # moduli must match
19261926
assert raises(lambda: R([F(1), F_other(2)]), ValueError) # moduli must match
19271927
assert raises(lambda: R([F(1), "A"]), TypeError) # need to be able to cast to fmpz_mod
@@ -2120,7 +2120,7 @@ def test_fmpz_mod_poly():
21202120
assert raises(lambda: f % f_bad, ValueError)
21212121
assert raises(lambda: 123 % f_bad, DomainError)
21222122
assert raises(lambda: f % "AAA", TypeError)
2123-
assert raises(lambda: tuple() % f, TypeError), f'{"AAA" % f = }'
2123+
assert raises(lambda: tuple() % f, TypeError)
21242124

21252125
assert f % 1 == 0
21262126
assert R_test.one() % 1 == 0
@@ -2550,7 +2550,7 @@ def test_polys():
25502550
assert P([S(1)]) == P([1]) == P(P([1])) == P(1)
25512551

25522552
assert raises(lambda: P([None]), TypeError)
2553-
assert raises(lambda: P(object()), TypeError), f"{P(object()) = }"
2553+
assert raises(lambda: P(object()), TypeError)
25542554
assert raises(lambda: P(None), TypeError)
25552555
assert raises(lambda: P(None, None), TypeError)
25562556
assert raises(lambda: P([1,2], None), TypeError)
@@ -2903,7 +2903,7 @@ def quick_poly():
29032903
assert ctx.constant(1) == mpoly({(0, 0): 1}) == P(1, ctx=ctx)
29042904

29052905
assert raises(lambda: P([None]), TypeError)
2906-
assert raises(lambda: P(object()), TypeError), f"{P(object()) = }"
2906+
assert raises(lambda: P(object()), TypeError)
29072907
assert raises(lambda: P(None), TypeError)
29082908
assert raises(lambda: P(None, None), TypeError)
29092909
assert raises(lambda: P([1,2], None), TypeError)

src/flint/types/fmpz_mod_poly.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ cdef class fmpz_mod_poly(flint_poly):
11861186
# For larger exponents we need to cast e to an fmpz first
11871187
e_fmpz = any_as_fmpz(e)
11881188
if e_fmpz is NotImplemented:
1189-
raise TypeError(f"exponent cannot be cast to an fmpz type: {e = }")
1189+
raise TypeError(f"exponent cannot be cast to an fmpz type: {e}")
11901190

11911191
# To optimise powering, we precompute the inverse of the reverse of the modulus
11921192
if mod_rev_inv is not None:
@@ -1716,7 +1716,7 @@ cdef class fmpz_mod_poly(flint_poly):
17161716
self.val, self.ctx.mod.val
17171717
)
17181718
if n > n_max:
1719-
raise ValueError(f"Cannot deflate with {n = }, maximum allowed value is {n_max = }")
1719+
raise ValueError(f"Cannot deflate with n = {n}, maximum allowed value is n_max = {n_max}")
17201720

17211721
res = self.ctx.new_ctype_poly()
17221722
fmpz_mod_poly_deflate(

src/flint/types/fq_default.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ cdef class fq_default_ctx:
5656

5757
# Now fq_type should be an int between 0, 5
5858
if not typecheck(fq_type, int):
59-
raise TypeError(f"{fq_type = } is invalid")
59+
raise TypeError(f"fq_type = {fq_type} is invalid")
6060
if fq_type < 0 or fq_type > 5:
61-
raise ValueError(f"{fq_type = } should be between 0 and 5")
61+
raise ValueError(f"fq_type = {fq_type} should be between 0 and 5")
6262

6363
return fq_type
6464

@@ -129,14 +129,14 @@ cdef class fq_default_ctx:
129129
# c_from_order expects the characteristic to be fmpz type
130130
prime = any_as_fmpz(p)
131131
if prime is NotImplemented:
132-
raise TypeError(f"cannot coerce {p = } to type fmpz")
132+
raise TypeError(f"cannot coerce p = {p} to type fmpz")
133133

134134
if check_prime and not prime.is_prime():
135135
raise ValueError("characteristic is not prime")
136136

137137
# the degree must be strictly positive
138138
if d < 1:
139-
raise ValueError(f"the degree must be positive, got {d = }")
139+
raise ValueError(f"the degree must be positive, got d = {d}")
140140

141141
fq_default_ctx_init_type(self.val, (<fmpz>prime).val, d, self.var, <fq_default_type>fq_type)
142142
self._initialized = True

src/flint/types/fq_default_poly.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cdef class fq_default_poly_ctx:
4747
# First coerce the list element as an fq_default type
4848
v = self.field.any_as_fq_default(val[i])
4949
if v is NotImplemented:
50-
raise TypeError(f"unsupported coefficient in list: {val[i] = }, {type(val[i]) = }")
50+
raise TypeError(f"unsupported coefficient in list: val[i] = {val[i]}, type(val[i] = {type(val[i])}")
5151

5252
# Set the coefficient of the polynomial
5353
fq_default_poly_set_coeff(
@@ -1324,7 +1324,7 @@ cdef class fq_default_poly(flint_poly):
13241324
"""
13251325
G, S, _ = self.xgcd(other)
13261326
if not G.is_one():
1327-
raise ValueError(f"polynomial has no inverse modulo {other = }")
1327+
raise ValueError(f"polynomial has no inverse modulo other = {other}")
13281328
return S
13291329

13301330
# ====================================
@@ -1638,7 +1638,7 @@ cdef class fq_default_poly(flint_poly):
16381638
self.val, self.ctx.field.val
16391639
)
16401640
if n > n_max:
1641-
raise ValueError(f"Cannot deflate with {n = }, maximum allowed value is {n_max = }")
1641+
raise ValueError(f"Cannot deflate with n = {n}, maximum allowed value is n_max = {n_max}")
16421642

16431643
res = self.ctx.new_ctype_poly()
16441644
fq_default_poly_deflate(

src/flint/types/nmod_poly.pyx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ cdef class nmod_poly(flint_poly):
262262
45*x^4 + 23*x^3 + 159*x^2 + 151*x + 110
263263
"""
264264
if n <= 0:
265-
raise ValueError(f"{n = } must be positive")
265+
raise ValueError(f"n = {n} must be positive")
266266

267267
if self.is_zero():
268268
raise ValueError("cannot invert the zero element")
@@ -315,11 +315,11 @@ cdef class nmod_poly(flint_poly):
315315
cdef nmod_poly res
316316
g = any_as_nmod_poly(other, self.val.mod)
317317
if g is NotImplemented:
318-
raise TypeError(f"cannot convert {other = } to nmod_poly")
318+
raise TypeError(f"cannot convert other = {other} to nmod_poly")
319319

320320
h = any_as_nmod_poly(modulus, self.val.mod)
321321
if h is NotImplemented:
322-
raise TypeError(f"cannot convert {modulus = } to nmod_poly")
322+
raise TypeError(f"cannot convert modulus = {modulus} to nmod_poly")
323323

324324
if modulus.is_zero():
325325
raise ZeroDivisionError("cannot reduce modulo zero")
@@ -549,7 +549,7 @@ cdef class nmod_poly(flint_poly):
549549
# For larger exponents we need to cast e to an fmpz first
550550
e_fmpz = any_as_fmpz(e)
551551
if e_fmpz is NotImplemented:
552-
raise TypeError(f"exponent cannot be cast to an fmpz type: {e = }")
552+
raise TypeError(f"exponent cannot be cast to an fmpz type: {e}")
553553

554554
# To optimise powering, we precompute the inverse of the reverse of the modulus
555555
if mod_rev_inv is not None:

0 commit comments

Comments
 (0)