Skip to content

Commit 54beefc

Browse files
Merge pull request #204 from fchapoton/cython-lint
first sketch of cython-lint workflow
2 parents 193054b + 96a6f0e commit 54beefc

30 files changed

+67
-98
lines changed

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Linting
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: ["3.11", "3.12"]
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Set up Python ${{ matrix.python-version }}
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
19+
- name: Install dependencies
20+
run: |
21+
pip install uv
22+
uv pip install cython-lint --upgrade --system
23+
24+
- name: cython-lint
25+
run: |
26+
cython-lint src/

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ content-type = "text/markdown"
3939
requires = ["meson-python>=0.13", "cython>=3.0,<3.1"]
4040
build-backend = "mesonpy"
4141

42+
[tool.cython-lint]
43+
max-line-length = 120
44+
ignore = ['E114','E117','E127','E128','E129','E202','E221','E222','E231','E261','E262','E265','E302','E303','E306','E501','E701','E703','E711','E722','E731','E741','E743','W391']
45+
exclude = 'src/flint/flintlib/.*'
46+
4247
[tool.spin]
4348
package = "flint"
4449

src/flint/pyflint.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
Python wrapper for FLINT and Arb.
33
"""
44

5-
cimport flint
5+
# cimport flint
66
cimport libc.stdlib
7-
cimport cython
87

98
from flint.flint_base.flint_context cimport thectx
109

src/flint/types/acb.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ cdef any_as_acb_or_notimplemented(x):
8787
return NotImplemented
8888
return t
8989

90-
"""
91-
cdef any_as_arb_or_acb(x):
92-
if typecheck(x, arb) or typecheck(x, acb):
93-
return x
94-
try:
95-
return arb(x)
96-
except (TypeError, ValueError):
97-
return acb(x)
98-
"""
90+
91+
# cdef any_as_arb_or_acb(x):
92+
# if typecheck(x, arb) or typecheck(x, acb):
93+
# return x
94+
# try:
95+
# return arb(x)
96+
# except (TypeError, ValueError):
97+
# return acb(x)
98+
9999

100100

101101
# Copied with modifications from sage/rings/complex_arb.pyx
@@ -2387,7 +2387,7 @@ cdef class acb(flint_scalar):
23872387
of terms to add in the hypergeometric series. This is just a tuning
23882388
parameter: a rigorous error bound is computed regardless of *n*.
23892389
"""
2390-
cdef long i, p, q, prec
2390+
cdef long i, p, q
23912391
cdef acb_ptr aa, bb
23922392
a = [any_as_acb(t) for t in a]
23932393
b = [any_as_acb(t) for t in b]

src/flint/types/acb_mat.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ cdef class acb_mat(flint_mat):
331331
return u
332332

333333
def __truediv__(s, t):
334-
cdef acb_mat u
335334
if typecheck(s, acb_mat):
336335
s, t = acb_mat_coerce_scalar(s, t)
337336
if s is NotImplemented:
@@ -597,7 +596,6 @@ cdef class acb_mat(flint_mat):
597596
return u
598597

599598
def __richcmp__(s, t, int op):
600-
cdef int stype, ttype
601599
cdef bint res
602600
if not (op == 2 or op == 3):
603601
raise ValueError("comparing matrices")

src/flint/types/acb_poly.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ cdef class acb_poly(flint_poly):
363363
ValueError: roots() failed to converge: insufficient precision, or squareful input
364364
365365
"""
366-
cdef long prec, initial_prec, target_prec, isolated, maxiter, deg, i
366+
cdef long prec, initial_prec, isolated, maxiter, deg, i
367367
cdef acb_ptr roots
368368
cdef acb_poly_t tmp
369369
deg = s.degree()

src/flint/types/acb_series.pyx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from flint.types.acb cimport acb
88
from flint.types.fmpz_poly cimport fmpz_poly
99
from flint.types.fmpq_poly cimport fmpq_poly
1010
from flint.types.arb_poly cimport arb_poly
11-
from flint.types.arb_poly cimport arb_poly_set_list
1211
from flint.types.acb_poly cimport acb_poly_set_list
1312
from flint.types.arb cimport arb
1413
from flint.types.acb_poly cimport acb_poly
@@ -629,7 +628,7 @@ cdef class acb_series(flint_series):
629628
of terms to add in the hypergeometric series. This is just a tuning
630629
parameter: a rigorous error bound is computed regardless of *n*.
631630
"""
632-
cdef long i, p, q, prec, cap
631+
cdef long i, p, q, cap
633632
cdef acb_poly_struct * aa
634633
cdef acb_poly_struct * bb
635634
a = [acb_series(t) for t in a]

src/flint/types/arb.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from flint.flint_base.flint_context cimport getprec
55
from flint.flint_base.flint_context cimport thectx
66
from flint.flint_base.flint_base cimport flint_scalar
77
from flint.utils.typecheck cimport typecheck
8-
from flint.utils.conversion cimport chars_from_str, str_from_chars, _str_trunc
8+
from flint.utils.conversion cimport chars_from_str, str_from_chars
99
from flint.types.fmpz cimport fmpz_set_pylong
1010
from flint.types.arf cimport arf
1111
from flint.types.fmpq cimport fmpq
@@ -43,7 +43,7 @@ cdef arb_from_str(str s):
4343
raise ValueError("invalid string for arb()")
4444

4545
cdef arb_set_mpmath_mpf(arb_t x, obj):
46-
sgn, man, exp, bc = obj
46+
sgn, man, exp, _ = obj
4747

4848
if not man:
4949
if not exp:
@@ -2171,7 +2171,7 @@ cdef class arb(flint_scalar):
21712171
>>> showgood(lambda: arb(5).hypgeom([1,2,3],[5,4.5,6],regularized=True), dps=25)
21722172
3.886189282817193519132054e-5
21732173
"""
2174-
cdef long i, p, q, prec
2174+
cdef long i, p, q
21752175
cdef arb_ptr aa, bb
21762176
a = [any_as_arb(t) for t in a]
21772177
b = [any_as_arb(t) for t in b]

src/flint/types/arb_mat.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,6 @@ cdef class arb_mat(flint_mat):
300300
return u
301301

302302
def __rmul__(s, t):
303-
cdef arb_mat u
304303
c, d = arb_mat_coerce_scalar(s, t)
305304
if c is not NotImplemented:
306305
return c._scalar_mul_(d)
@@ -317,7 +316,6 @@ cdef class arb_mat(flint_mat):
317316
return u
318317

319318
def __truediv__(s, t):
320-
cdef arb_mat u
321319
s, t = arb_mat_coerce_scalar(s, t)
322320
if s is NotImplemented:
323321
return s
@@ -669,7 +667,6 @@ cdef class arb_mat(flint_mat):
669667
return u
670668

671669
def __richcmp__(s, t, int op):
672-
cdef int stype, ttype
673670
cdef bint res
674671
if not (op == 2 or op == 3):
675672
raise ValueError("comparing matrices")

src/flint/types/arb_poly.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ from flint.types.acb_poly cimport acb_poly
1414

1515
from flint.flintlib.arb cimport *
1616
from flint.flintlib.arb_poly cimport *
17-
cimport cython
1817
cimport libc.stdlib
1918

2019
cdef arb_poly_coerce_operands(x, y):

0 commit comments

Comments
 (0)