Skip to content

Commit bac34d9

Browse files
authored
Merge pull request #6385 from fchapoton/more_checks_in_lint
more checks and faster with ruff
2 parents 09bb448 + 7e17583 commit bac34d9

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
shell: bash -l {0}
8686
run: |
8787
sage -pip install -r requirements.txt
88-
pip install pyflakes pylint pycodestyle
88+
pip install pyflakes pylint pycodestyle ruff
8989
9090
- name: checking that we didn't miss any test files
9191
shell: bash -l {0}

lmfdb/groups/abstract/test_abstract_groups.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,21 @@ def test_is_solvable(self):
1010
self.check_args("/Groups/Abstract/60.5", "nonsolvable")
1111
self.check_args("/Groups/Abstract/32.51", "solvable")
1212

13-
# To do: Test a lot more data, also more property box tests
13+
# To do: Test a lot more data, also more property box tests
1414

1515
def test_property_box(self):
1616
r"""
1717
Check that the property box displays.
1818
"""
1919
page = self.tc.get("/Groups/Abstract/256.14916").get_data(as_text=True).replace("\n", "").replace(" ", "")
2020
assert r'<divclass="properties-body"><table><tr><tdclass="label">Label</td><td>256.14916</td></tr><tr>' in page
21-
# assert r'<tdclass="label">Order</td><td>${2^{8}}$</td></tr>' in page
22-
# self.check_args("/Variety/Abelian/Fq/2/79/ar_go", "Principally polarizable")
21+
# assert r'<tdclass="label">Order</td><td>${2^{8}}$</td></tr>' in page
22+
# self.check_args("/Variety/Abelian/Fq/2/79/ar_go", "Principally polarizable")
2323

2424
def test_abstract_group_download(self):
25-
# r"""
26-
# Test downloading on search results page.
25+
r"""
26+
Test downloading on search results page.
27+
"""
2728
response = self.tc.get("/Groups/Abstract/384.5458/download/gap")
2829
self.assertTrue("If the group is solvable" in response.get_data(as_text=True))
2930
self.assertTrue("encd:= 293961739841108398509157889" in response.get_data(as_text=True))

lmfdb/groups/abstract/web_groups.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,13 @@ def split_matrix_list_Fp(longList,d,e):
140140

141141

142142
def split_matrix_list_Fq(longList,d, Fqfld):
143-
# for gap definition of Fq
143+
# for gap definition of Fq
144144
longList = [f"0*Z({Fqfld})" if x == -1 else f"Z({Fqfld})^{x}" for x in longList] #-1 distinguishes 0 from z^0
145145
return str([longList[i:i+d] for i in range(0,d**2,d)]).replace("'", "")
146146

147147

148148
def split_matrix_Fq_add_al(longList,d):
149-
# for magma definition of Fq
149+
# for magma definition of Fq
150150
longList = [0 if x == -1 else 1 if x == 0 else f"al^{x}" for x in longList]
151151
return str([longList[i:i+d] for i in range(0,d**2,d)]).replace("'", "")
152152

@@ -662,8 +662,8 @@ def number_conjugacy_classes(self):
662662

663663
@lazy_attribute
664664
def cc_known(self):
665-
# if self.representations.get("Lie") and self.representations["Lie"][0]["family"][0] == "P" and self.order < 2000:
666-
# return False # problem with PGL, PSL, etc.
665+
# if self.representations.get("Lie") and self.representations["Lie"][0]["family"][0] == "P" and self.order < 2000:
666+
# return False # problem with PGL, PSL, etc.
667667
return db.gps_conj_classes.exists({'group_order': self.order, 'group_counter': self.counter})
668668

669669
@lazy_attribute

lmfdb/local_fields/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,12 @@ def render_field_webpage(args):
425425
galphrase = 'This field is'+isgal+abelian+r' over $\Q_{%d}.$' % p
426426
if the_gal.order() == gn:
427427
auttype = 'gal'
428-
info['aut_gp_knowl']= the_gal.aut_knowl()
428+
info['aut_gp_knowl'] = the_gal.aut_knowl()
429429
# we don't know the Galois group, but maybe the Aut group is obvious
430-
elif data['aut']==1:
431-
info['aut_gp_knowl']=abstract_group_display_knowl('1.1')
430+
elif data['aut'] == 1:
431+
info['aut_gp_knowl'] = abstract_group_display_knowl('1.1')
432432
elif is_prime(data['aut']):
433-
info['aut_gp_knowl']=abstract_group_display_knowl(f"{data['aut']}.1")
433+
info['aut_gp_knowl'] = abstract_group_display_knowl(f"{data['aut']}.1")
434434
prop2 = [
435435
('Label', label),
436436
('Base', r'\(%s\)' % Qp),

lmfdb/number_fields/draw_spectrum.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def unram_coords(frob_cycle_list, x_coord, y_centre, spread, col_max):
197197
point_index = 0 # total index of point
198198
for cyc_len, num_repeats in frob_cycle_list:
199199
for _ in range(num_repeats):
200-
y_offset = round(spread*(2*point_index /(N-1) -1))
200+
y_offset = round(spread * (2 * point_index / (N - 1) - 1))
201201
point = Point(x_coord, y_centre - y_offset, cyc_len)
202202
point_list.append(point)
203203
point_index += 1
@@ -213,13 +213,13 @@ def ram_coords(local_alg_dict, p, x_coord, y_centre, spread, deg=1):
213213
N = len(algs)
214214
assert algs != [], f"Ramified prime {p} has no local data!"
215215

216-
max_ram_index = max(e for e,_ in algs)
216+
max_ram_index = max(e for e, _ in algs)
217217
point_list = []
218218

219219
for i, alg in enumerate(algs):
220220
ram_index, residue_deg = alg
221221
if N != 1:
222-
y_offset = round(spread*(2*i /(N-1) -1))
222+
y_offset = round(spread * (2 * i / (N - 1) - 1))
223223
else:
224224
y_offset = 0
225225
point = Point(x_coord, y_centre - y_offset, residue_deg, hsl_color(ram_index, max_ram_index))
@@ -257,7 +257,7 @@ def test_drawspec(n=1, gaga=False):
257257
canvas = draw_spec(frobs, local_algs, True,
258258
gaga=gaga,num_primes=num_primes)
259259
import tempfile
260-
filename = tempfile.gettempdir() + ('/gaga' if gaga else '/spec') + ".svg"
260+
filename = tempfile.gettempdir() + ('/gaga' if gaga else '/spec') + ".svg"
261261
with open(filename, mode='w') as f:
262262
f.write(canvas.as_str())
263263

tox.ini

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ commands =
2020
whitelist_externals =
2121
pyflakes
2222
pylint
23-
# pycodestyle
23+
ruff
2424

2525
commands =
2626
pyflakes start-lmfdb.py user-manager.py lmfdb/
2727
pylint --score=no -d C,R,E,W -e W0129,W0108 start-lmfdb.py user-manager.py lmfdb/
2828
# see https://pycodequ.al/docs/pylint-messages/Warnings.html
2929
# E111 indentation is not a multiple of four
30+
# E115 Expected an indented block (comment)
3031
# E211 whitespace before '('
32+
# E222 Multiple spaces after operator
33+
# E225 Missing whitespace around operator
3134
# E702 multiple statements on one line (semicolon)
3235
# E711 Comparison to None should be 'cond is None:'
3336
# E722 do not use bare except, specify exception instead
34-
pycodestyle --select=E111,E211,E702,E711,E722 lmfdb/
37+
ruff check --preview --select=E111,E115,E211,E222,E225,E702,E711,E722 lmfdb/

0 commit comments

Comments
 (0)