From 3156d8420237254aa93a22337f21729a1a024ccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 29 Apr 2026 14:00:21 +0200 Subject: [PATCH 1/2] check E261 using cython-lint --- pyproject.toml | 2 +- src/flint/types/acb_poly.pyx | 2 +- src/flint/types/arb_poly.pyx | 2 +- src/flint/types/fmpq.pyx | 2 +- src/flint/types/fmpz.pyx | 2 +- src/flint/types/fmpz_mod_poly.pyx | 10 +++++----- src/flint/types/fq_default_poly.pyx | 10 +++++----- src/flint/types/nmod_mat.pyx | 2 +- src/flint/types/nmod_poly.pyx | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index bfd3dee8..e2392205 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ build-backend = "mesonpy" [tool.cython-lint] max-line-length = 120 -ignore = ['E128','E129','E202','E221','E222','E261','E262','E265','E501','E731','E741','E743'] +ignore = ['E128','E129','E202','E221','E222','E262','E265','E501','E731','E741','E743'] exclude = 'src/flint/flintlib/.*' [tool.spin] diff --git a/src/flint/types/acb_poly.pyx b/src/flint/types/acb_poly.pyx index 712c5980..066473c5 100644 --- a/src/flint/types/acb_poly.pyx +++ b/src/flint/types/acb_poly.pyx @@ -197,7 +197,7 @@ cdef class acb_poly(flint_poly): return u def __pos__(self): - return self # ? + return self # ? def __neg__(s): u = acb_poly.__new__(acb_poly) diff --git a/src/flint/types/arb_poly.pyx b/src/flint/types/arb_poly.pyx index 6c69745d..787b3f00 100644 --- a/src/flint/types/arb_poly.pyx +++ b/src/flint/types/arb_poly.pyx @@ -194,7 +194,7 @@ cdef class arb_poly(flint_poly): return u def __pos__(self): - return self # ? + return self # ? def __neg__(s): u = arb_poly.__new__(arb_poly) diff --git a/src/flint/types/fmpq.pyx b/src/flint/types/fmpq.pyx index 669d79d2..c4569426 100644 --- a/src/flint/types/fmpq.pyx +++ b/src/flint/types/fmpq.pyx @@ -67,7 +67,7 @@ cdef class fmpq(flint_scalar): def __init__(self, *args): if not args: - return # zero + return # zero elif len(args) == 2: p, q = args elif len(args) == 1: diff --git a/src/flint/types/fmpz.pyx b/src/flint/types/fmpz.pyx index e5b6f4cb..9bdac70e 100644 --- a/src/flint/types/fmpz.pyx +++ b/src/flint/types/fmpz.pyx @@ -77,7 +77,7 @@ cdef class fmpz(flint_scalar): if typecheck(val, fmpz): fmpz_set(self.val, (val).val) else: - if fmpz_set_any_ref(self.val, val) == FMPZ_UNKNOWN: # XXX + if fmpz_set_any_ref(self.val, val) == FMPZ_UNKNOWN: # XXX if typecheck(val, str): if fmpz_set_str(self.val, chars_from_str(val), 10) != 0: raise ValueError("invalid string for fmpz") diff --git a/src/flint/types/fmpz_mod_poly.pyx b/src/flint/types/fmpz_mod_poly.pyx index 0e1b579b..04471d0f 100644 --- a/src/flint/types/fmpz_mod_poly.pyx +++ b/src/flint/types/fmpz_mod_poly.pyx @@ -39,7 +39,7 @@ cdef class fmpz_mod_poly_ctx: # Allow context to be made from fmpz_mod_ctx if typecheck(mod, fmpz_mod_ctx): self.mod = mod - else: # Otherwise attempt to create context from moduli + else: # Otherwise attempt to create context from moduli self.mod = fmpz_mod_ctx(mod) def modulus(self): @@ -579,7 +579,7 @@ cdef class fmpz_mod_poly(flint_poly): fmpz_mod_poly_shift_left( res.val, self.val, n, self.ctx.mod.val ) - else: # do nothing, just copy self + else: # do nothing, just copy self fmpz_mod_poly_set( res.val, self.val, self.ctx.mod.val ) @@ -612,7 +612,7 @@ cdef class fmpz_mod_poly(flint_poly): fmpz_mod_poly_shift_right( res.val, self.val, n, self.ctx.mod.val ) - else: # do nothing, just copy self + else: # do nothing, just copy self fmpz_mod_poly_set( res.val, self.val, self.ctx.mod.val ) @@ -1004,9 +1004,9 @@ cdef class fmpz_mod_poly(flint_poly): length = fmpz_mod_poly_degree(self.val, self.ctx.mod.val) res = self.ctx.new_ctype_poly() - if n <= 0: # return zero + if n <= 0: # return zero return res - elif n > length: # do nothing + elif n > length: # do nothing fmpz_mod_poly_set( res.val, self.val, self.ctx.mod.val ) diff --git a/src/flint/types/fq_default_poly.pyx b/src/flint/types/fq_default_poly.pyx index 982607e8..64503eee 100644 --- a/src/flint/types/fq_default_poly.pyx +++ b/src/flint/types/fq_default_poly.pyx @@ -31,7 +31,7 @@ cdef class fq_default_poly_ctx: # Allow context to be made from fq_default_ctx if len(args) == 1 and typecheck(args[0], fq_default_ctx): self.field = args[0] - else: # Otherwise attempt to create context from moduli + else: # Otherwise attempt to create context from moduli self.field = fq_default_ctx(*args, **kwargs) cdef set_list_as_fq_default_poly(self, fq_default_poly_t poly, val): @@ -431,9 +431,9 @@ cdef class fq_default_poly(flint_poly): length = fq_default_poly_degree(self.val, self.ctx.field.val) res = self.ctx.new_ctype_poly() - if n <= 0: # return zero + if n <= 0: # return zero return res - elif n > length: # do nothing + elif n > length: # do nothing fq_default_poly_set( res.val, self.val, self.ctx.field.val ) @@ -923,7 +923,7 @@ cdef class fq_default_poly(flint_poly): fq_default_poly_shift_left( res.val, self.val, n, self.ctx.field.val ) - else: # do nothing, just copy self + else: # do nothing, just copy self fq_default_poly_set( res.val, self.val, self.ctx.field.val ) @@ -956,7 +956,7 @@ cdef class fq_default_poly(flint_poly): fq_default_poly_shift_right( res.val, self.val, n, self.ctx.field.val ) - else: # do nothing, just copy self + else: # do nothing, just copy self fq_default_poly_set( res.val, self.val, self.ctx.field.val ) diff --git a/src/flint/types/nmod_mat.pyx b/src/flint/types/nmod_mat.pyx index fc5b36ba..3a8e059a 100644 --- a/src/flint/types/nmod_mat.pyx +++ b/src/flint/types/nmod_mat.pyx @@ -198,7 +198,7 @@ cdef class nmod_mat(flint_mat): i, j = index if i < 0 or i >= self.nrows() or j < 0 or j >= self.ncols(): raise IndexError("index %i,%i exceeds matrix dimensions" % (i, j)) - x = nmod(nmod_mat_entry(self.val, i, j), self.modulus()) # XXX: slow + x = nmod(nmod_mat_entry(self.val, i, j), self.modulus()) # XXX: slow return x def __setitem__(self, index, value): diff --git a/src/flint/types/nmod_poly.pyx b/src/flint/types/nmod_poly.pyx index 020448b2..f994775a 100644 --- a/src/flint/types/nmod_poly.pyx +++ b/src/flint/types/nmod_poly.pyx @@ -38,7 +38,7 @@ cdef nmod_poly_set_list(nmod_poly_t poly, list val): cdef long i, n cdef nmod_t mod cdef mp_limb_t v - nmod_init(&mod, nmod_poly_modulus(poly)) # XXX + nmod_init(&mod, nmod_poly_modulus(poly)) # XXX n = PyList_GET_SIZE(val) nmod_poly_fit_length(poly, n) for i from 0 <= i < n: From 386a450c0f2697a13096ccc1248204b950acb431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Wed, 29 Apr 2026 14:13:31 +0200 Subject: [PATCH 2/2] also fix E222 --- pyproject.toml | 2 +- src/flint/types/fq_default_poly.pyx | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e2392205..c15b44a3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ build-backend = "mesonpy" [tool.cython-lint] max-line-length = 120 -ignore = ['E128','E129','E202','E221','E222','E262','E265','E501','E731','E741','E743'] +ignore = ['E128','E129','E202','E221','E262','E265','E501','E731','E741','E743'] exclude = 'src/flint/flintlib/.*' [tool.spin] diff --git a/src/flint/types/fq_default_poly.pyx b/src/flint/types/fq_default_poly.pyx index 64503eee..8bc7e99a 100644 --- a/src/flint/types/fq_default_poly.pyx +++ b/src/flint/types/fq_default_poly.pyx @@ -453,7 +453,7 @@ cdef class fq_default_poly(flint_poly): x^2 + 55*x + 109 """ cdef fq_default_poly res - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_make_monic( res.val, self.val, self.ctx.field.val ) @@ -563,7 +563,7 @@ cdef class fq_default_poly(flint_poly): def __neg__(self): cdef fq_default_poly res - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_neg( res.val, self.val, self.ctx.field.val ) @@ -576,7 +576,7 @@ cdef class fq_default_poly(flint_poly): if other is NotImplemented: return NotImplemented - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_add( res.val, self.val, (other).val, self.ctx.field.val ) @@ -592,7 +592,7 @@ cdef class fq_default_poly(flint_poly): if other is NotImplemented: return NotImplemented - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_sub( res.val, self.val, (other).val, self.ctx.field.val ) @@ -605,7 +605,7 @@ cdef class fq_default_poly(flint_poly): if other is NotImplemented: return NotImplemented - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_sub( res.val, (other).val, self.val, self.ctx.field.val ) @@ -613,7 +613,7 @@ cdef class fq_default_poly(flint_poly): def __mul__(self, other): cdef fq_default_poly res - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() # First try scalar multiplication if not typecheck(other, fq_default_poly): @@ -766,7 +766,7 @@ cdef class fq_default_poly(flint_poly): def __truediv__(self, other): cdef fq_default_poly res - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() # First try scalar division if not typecheck(other, fq_default_poly): @@ -854,7 +854,7 @@ cdef class fq_default_poly(flint_poly): if other.is_zero(): raise ZeroDivisionError("Cannot compute remainder modulo 0") - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_rem( res.val, self.val, (other).val, self.ctx.field.val ) @@ -870,7 +870,7 @@ cdef class fq_default_poly(flint_poly): if other is NotImplemented: return NotImplemented - res = self.ctx.new_ctype_poly() + res = self.ctx.new_ctype_poly() fq_default_poly_rem( res.val, (other).val, self.val, self.ctx.field.val )