Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and activate some checks in ruff-minimal #39231

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/sage/combinat/matrices/latin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,8 @@ def disjoint_mate_dlxcpp_rows_and_map(self, allow_subtrade):

dlx_rows.append([c_OFFSET, r_OFFSET, xy_OFFSET])

max_column_nr = max(max_column_nr, max(c_OFFSET, r_OFFSET, xy_OFFSET))
max_column_nr = max(max_column_nr, c_OFFSET,
r_OFFSET, xy_OFFSET)

# We will have missed some columns. We
# have to add 'dummy' rows so that the C++ DLX solver will find
Expand Down
4 changes: 2 additions & 2 deletions src/sage/doctest/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,12 +1351,12 @@
opt = self.options

if opt.gdb:
cmd = f'''exec gdb --eval-command="run" --args '''
cmd = '''exec gdb --eval-command="run" --args '''
flags = ""
if opt.logfile:
sage_cmd += f" --logfile {shlex.quote(opt.logfile)}"
elif opt.lldb:
cmd = f'''exec lldb --one-line "process launch" --one-line "cont" -- '''
cmd = '''exec lldb --one-line "process launch" --one-line "cont" -- '''

Check warning on line 1359 in src/sage/doctest/control.py

View check run for this annotation

Codecov / codecov/patch

src/sage/doctest/control.py#L1359

Added line #L1359 was not covered by tests
flags = ""
else:
if opt.logfile is None:
Expand Down
8 changes: 4 additions & 4 deletions src/sage/functions/airy.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _evalf_(self, x, **kwargs):
from sage.rings.real_mpfr import RR
from sage.rings.cc import CC
from sage.functions.other import real, imag
from scipy.special import airy as airy
from scipy.special import airy
if x in RR:
y = airy(real(x))[0]
if parent is None:
Expand Down Expand Up @@ -341,7 +341,7 @@ def _evalf_(self, x, **kwargs):
from sage.rings.real_mpfr import RR
from sage.rings.cc import CC
from sage.functions.other import real, imag
from scipy.special import airy as airy
from scipy.special import airy
if x in RR:
y = airy(real(x))[1]
if parent is None:
Expand Down Expand Up @@ -680,7 +680,7 @@ def _evalf_(self, x, **kwargs):
from sage.rings.real_mpfr import RR
from sage.rings.cc import CC
from sage.functions.other import real, imag
from scipy.special import airy as airy
from scipy.special import airy
if x in RR:
y = airy(real(x))[2]
if parent is None:
Expand Down Expand Up @@ -782,7 +782,7 @@ def _evalf_(self, x, **kwargs):
from sage.rings.real_mpfr import RR
from sage.rings.cc import CC
from sage.functions.other import real, imag
from scipy.special import airy as airy
from scipy.special import airy
if x in RR:
y = airy(real(x))[3]
if parent is None:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/functions/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Tomas Kalvoda (2015-04-01): Add :meth:`exp_polar()` (:issue:`18085`)
"""

from sage.misc.functional import log as log
from sage.misc.functional import log
from sage.misc.lazy_import import lazy_import
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/generators/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -1709,7 +1709,7 @@ def RandomKTree(n, k, seed=None):

# A graph with treewidth 0 has no edges
if k == 0:
g = Graph(n, name=f"Random 0-tree")
g = Graph(n, name="Random 0-tree")
return g

if n < k + 1:
Expand Down Expand Up @@ -1803,7 +1803,7 @@ def RandomPartialKTree(n, k, x, seed=None):

# A graph with treewidth 0 has no edges
if k == 0:
g = Graph(n, name=f"Random partial 0-tree")
g = Graph(n, name="Random partial 0-tree")
return g

if n < k + 1:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/package_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@
else:
handle_file(*os.path.split(path))

print(f"sage --fixdistributions: checking consistency")
print("sage --fixdistributions: checking consistency")

Check warning on line 606 in src/sage/misc/package_dir.py

View check run for this annotation

Codecov / codecov/patch

src/sage/misc/package_dir.py#L606

Added line #L606 was not covered by tests

for package in ordinary_packages:
if len(package_distributions_per_directives[package]) > 1:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/modules/with_basis/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1895,7 +1895,7 @@ def __init__(self, rep, degree, **options):
R = rep.base_ring()
dim = rep.dimension()
if degree not in ZZ or degree < 0:
raise ValueError(f"the degree must be a nonnegative integer")
raise ValueError("the degree must be a nonnegative integer")
self._symalg = PolynomialRing(R, 'e', dim)
self._basis_order = list(rep.basis().keys())
G = self._symalg.gens()
Expand Down
3 changes: 1 addition & 2 deletions src/sage/quadratic_forms/quadratic_form__ternary_Tornaria.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def adjoint(self):
[ * 19 4 ]
[ * * 8 ]
"""
from sage.quadratic_forms.quadratic_form import QuadraticForm as QuadraticForm

from sage.quadratic_forms.quadratic_form import QuadraticForm
if is_odd(self.dim()):
return QuadraticForm(self.matrix().adjoint_classical() * 2)
return QuadraticForm(self.matrix().adjoint_classical())
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/curves/projective_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@
sage: set_verbose(-1)
sage: P.<x,y,z> = ProjectiveSpace(QQ, 2)
sage: C = Curve([(x^2 + y^2 - y*z - 2*z^2)*(y*z - x^2 + 2*z^2)*z + y^5], P)
sage: C.ordinary_model() # long time (5 seconds)

Check warning on line 1403 in src/sage/schemes/curves/projective_curve.py

View workflow job for this annotation

GitHub Actions / test-new

Warning: slow doctest:

slow doctest:
Scheme morphism:
From: Projective Plane Curve over Number Field in a
with defining polynomial y^2 - 2 defined
Expand Down Expand Up @@ -2300,7 +2300,7 @@
self._open_affine_index = i
break
else:
assert "no projective curve defined"
raise ValueError("no projective curve defined")

Check warning on line 2303 in src/sage/schemes/curves/projective_curve.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/curves/projective_curve.py#L2303

Added line #L2303 was not covered by tests

def function_field(self):
"""
Expand Down
7 changes: 4 additions & 3 deletions src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
Original file line number Diff line number Diff line change
Expand Up @@ -3319,12 +3319,13 @@

else:
# trac 7096
# this should take care of the case when the isogeny is not normalized.
# this should take care of the case when the isogeny is
# not normalized.
u = self.scaling_factor()
E2 = E2pr.change_weierstrass_model(u/F(d), 0, 0, 0)

phi_hat = EllipticCurveIsogeny(E1, None, E2, d)
# assert phi_hat.scaling_factor() == 1
# assert phi_hat.scaling_factor() == 1

for pre_iso in self._codomain.isomorphisms(E1):
for post_iso in E2.isomorphisms(self._domain):
Expand All @@ -3335,7 +3336,7 @@
continue
break
else:
assert "bug in dual()"
raise RuntimeError("bug in dual()")

Check warning on line 3339 in src/sage/schemes/elliptic_curves/ell_curve_isogeny.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/elliptic_curves/ell_curve_isogeny.py#L3339

Added line #L3339 was not covered by tests

phi_hat._set_pre_isomorphism(pre_iso)
phi_hat._set_post_isomorphism(post_iso)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/elliptic_curves/ell_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,7 +1754,7 @@
if not f.is_irreducible():
raise NotImplementedError('currently, kernel_polynomial_from_divisor() only supports irreducible polynomials')
if f.parent().base_ring() != self.base_ring():
raise TypeError(f'given polynomial is not defined over the base ring of the curve')
raise TypeError('given polynomial is not defined over the base ring of the curve')

Check warning on line 1757 in src/sage/schemes/elliptic_curves/ell_field.py

View check run for this annotation

Codecov / codecov/patch

src/sage/schemes/elliptic_curves/ell_field.py#L1757

Added line #L1757 was not covered by tests
if self.division_polynomial(l, x=f.parent().quotient_ring(f).gen()):
raise ValueError(f'given polynomial does not divide the {l}-division polynomial')

Expand Down
6 changes: 3 additions & 3 deletions src/sage/tests/arxiv_0812_2725.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
sage: dcrossing([(1,5), (2,4), (4,9), (6,12), (7,10), (10,11)])
3
"""
#*****************************************************************************
# ****************************************************************************
# Copyright (C) 2008 Dan Drake <ddrake@member.ams.org>
#
# This program is free software: you can redistribute it and/or modify
Expand All @@ -34,8 +34,8 @@
# your option) any later version.
#
# See https://www.gnu.org/licenses/.
#*****************************************************************************
from sage.combinat.set_partition import SetPartitions as SetPartitions
# ****************************************************************************
from sage.combinat.set_partition import SetPartitions


def CompleteMatchings(n):
Expand Down
4 changes: 1 addition & 3 deletions src/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -304,16 +304,14 @@ passenv = RUFF_OUTPUT_FORMAT
# 7 E743 [ ] Ambiguous function name: `I`
# 7 PLR0124 [ ] Name compared with itself, consider replacing `a == a`
# 5 PLW0127 [ ] Self-assignment of variable `a`
# 4 F541 [*] f-string without any placeholders
# 4 PLW1508 [ ] Invalid type for environment variable default; expected `str` or `None`
# 3 PLC3002 [ ] Lambda expression called directly. Execute the expression inline instead.
# 2 E742 [ ] Ambiguous class name: `I`
# 2 PLE0302 [ ] The special method `__len__` expects 1 parameter, 3 were given
# 2 PLW0129 [ ] Asserting on a non-empty string literal will always pass
# 1 F402 [ ] Import `factor` from line 259 shadowed by loop variable
# 1 PLC0208 [*] Use a sequence type instead of a `set` when iterating over values
#
commands = ruff check --ignore E402,E721,E731,E741,E742,E743,F401,F402,F403,F405,F541,F811,F821,F841,I001,PLC0206,PLC0208,PLC0414,PLC2401,PLC3002,PLE0302,PLR0124,PLR0402,PLR0911,PLR0912,PLR0913,PLR0915,PLR1704,PLR1711,PLR1714,PLR1736,PLR2004,PLR5501,PLW0120,PLW0127,PLW0129,PLW0211,PLW0602,PLW0603,PLW0642,PLW1508,PLW1510,PLW2901,PLW3301 {posargs:{toxinidir}/sage/}
commands = ruff check --ignore E402,E721,E731,E741,E742,E743,F401,F402,F403,F405,F811,F821,F841,I001,PLC0206,PLC0208,PLC2401,PLC3002,PLE0302,PLR0124,PLR0402,PLR0911,PLR0912,PLR0913,PLR0915,PLR1704,PLR1711,PLR1714,PLR1736,PLR2004,PLR5501,PLW0120,PLW0127,PLW0211,PLW0602,PLW0603,PLW0642,PLW1508,PLW1510,PLW2901,PLW3301 {posargs:{toxinidir}/sage/}

[flake8]
rst-roles =
Expand Down
Loading