Skip to content
Open
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
9 changes: 5 additions & 4 deletions src/sage/modular/abvar/finite_subgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class FiniteSubgroup(Module):

Element = TorsionPoint

def __init__(self, abvar, field_of_definition=QQ):
def __init__(self, abvar, field_of_definition=QQ) -> None:
"""
Initialize ``self``.

Expand Down Expand Up @@ -215,7 +215,7 @@ def _relative_basis_matrix(self):
return M

# General functionality
def __richcmp__(self, other, op):
def __richcmp__(self, other, op) -> bool:
"""
Compare ``self`` to ``other``.

Expand Down Expand Up @@ -693,7 +693,7 @@ def _element_constructor_(self, x, check=True):
x = self.lattice()(x, check=check)
return self.element_class(self, x, check=False)

def __contains__(self, x):
def __contains__(self, x) -> bool:
"""
Return ``True`` if ``x`` is contained in this finite subgroup.

Expand Down Expand Up @@ -837,7 +837,8 @@ def invariants(self):


class FiniteSubgroup_lattice(FiniteSubgroup):
def __init__(self, abvar, lattice, field_of_definition=None, check=True):
def __init__(self, abvar, lattice,
field_of_definition=None, check=True) -> None:
"""
A finite subgroup of a modular abelian variety that is defined by a
given lattice.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modular/arithgroup/arithgroup_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _element_constructor_(self, x, check=True):
return x
raise TypeError("matrix %s is not an element of %s" % (x, self))

def __contains__(self, x):
def __contains__(self, x) -> bool:
r"""
Test if x is an element of this group.

Expand Down Expand Up @@ -200,7 +200,7 @@ def _contains_sl2(self, a, b, c, d):
"""
raise NotImplementedError("Please implement _contains_sl2 for %s" % self.__class__)

def __hash__(self):
def __hash__(self) -> int:
r"""
Return a hash of ``self``.

Expand Down
6 changes: 3 additions & 3 deletions src/sage/modular/arithgroup/farey_symbol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ cdef class Farey:
else: # output == 'gens'
return tuple((gens[a-1], len(list(g))) if a > 0 else (gens[-a-1], -len(list(g))) for a, g in groupby(tietze))

def __contains__(self, M):
def __contains__(self, M) -> bool:
r"""
Test if element is in the arithmetic group of the Farey symbol
via LLT algorithm.
Expand All @@ -533,7 +533,7 @@ cdef class Farey:
sig_off()
return result

def __richcmp__(self, other, op):
def __richcmp__(self, other, op) -> bool:
r"""
Compare ``self`` to ``other``.

Expand Down Expand Up @@ -569,7 +569,7 @@ cdef class Farey:
"""
return Farey, (self.group, self.this_ptr.dumps())

def __repr__(self):
def __repr__(self) -> str:
r"""
Return the string representation of ``self``.

Expand Down
20 changes: 10 additions & 10 deletions src/sage/modules/fg_pid/fgp_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class FGP_Module_class(Module):
# module. Should be overridden in derived classes.
Element = FGP_Element

def __init__(self, V, W, check=True):
def __init__(self, V, W, check=True) -> None:
"""
INPUT:

Expand Down Expand Up @@ -470,7 +470,7 @@ def _mul_(self, other, switch_sides=False):
raise ValueError("Scalar multiplication of a module is only " +
"defined for an element of the base ring.")

def _repr_(self):
def _repr_(self) -> str:
"""
Return string representation of this module.

Expand Down Expand Up @@ -507,9 +507,9 @@ def __truediv__(self, other):
raise TypeError("other must be an FGP module")
if not other.is_submodule(self):
raise ValueError("other must be a submodule of self")
return self._module_constructor(self._V, other._V+self._W)
return self._module_constructor(self._V, other._V + self._W)

def __eq__(self, other):
def __eq__(self, other) -> bool:
"""
EXAMPLES::

Expand All @@ -529,7 +529,7 @@ def __eq__(self, other):
return False
return self._V == other._V and self._W == other._W

def __ne__(self, other):
def __ne__(self, other) -> bool:
"""
Return ``True`` iff ``self`` is not equal to ``other``.

Expand Down Expand Up @@ -569,7 +569,7 @@ def __ne__(self, other):

# __le__ is a synonym for `is_submodule`: see below

def __lt__(self, other):
def __lt__(self, other) -> bool:
"""
Return ``True`` iff ``self`` is a proper submodule of ``other``.

Expand All @@ -587,7 +587,7 @@ def __lt__(self, other):
"""
return self <= other and not self == other

def __gt__(self, other):
def __gt__(self, other) -> bool:
"""
Return ``True`` iff ``other`` is a proper submodule of ``self``.

Expand All @@ -605,7 +605,7 @@ def __gt__(self, other):
"""
return self >= other and not self == other

def __ge__(self, other):
def __ge__(self, other) -> bool:
"""
Return ``True`` iff ``other`` is a submodule of ``self``.

Expand Down Expand Up @@ -675,7 +675,7 @@ def linear_combination_of_smith_form_gens(self, x):
raise TypeError(msg)
return self.element_class(self, self._V(x))

def __contains__(self, x):
def __contains__(self, x) -> bool:
"""
Return true if ``x`` is contained in ``self``.

Expand Down Expand Up @@ -1940,7 +1940,7 @@ def ngens(self):
"""
return len(self.gens())

def __hash__(self):
def __hash__(self) -> int:
r"""
Calculate a hash for ``self``.

Expand Down
6 changes: 3 additions & 3 deletions src/sage/modules/with_basis/indexed_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cdef class IndexedFreeModuleElement(ModuleElement):
sage: isinstance(f, collections.abc.Collection) # known bug - will be fixed by removing __contains__
False
"""
def __init__(self, M, x):
def __init__(self, M, x) -> None:
"""
Create a combinatorial module element.

Expand Down Expand Up @@ -84,7 +84,7 @@ cdef class IndexedFreeModuleElement(ModuleElement):
"""
return iter(self._monomial_coefficients.items())

def __contains__(self, x):
def __contains__(self, x) -> bool:
"""
Return whether or not a combinatorial object ``x`` indexing a basis
element is in the support of ``self``.
Expand Down Expand Up @@ -113,7 +113,7 @@ cdef class IndexedFreeModuleElement(ModuleElement):
deprecation(34509, "using 'index in vector' is deprecated; use 'index in vector.support()' instead")
return x in self.support()

def __hash__(self):
def __hash__(self) -> int:
"""
Return the hash value for ``self``.

Expand Down
28 changes: 14 additions & 14 deletions src/sage/plot/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def rgbcolor(c, space='rgb'):


class Color:
def __init__(self, r='#0000ff', g=None, b=None, space='rgb'):
def __init__(self, r='#0000ff', g=None, b=None, space='rgb') -> None:
"""
A Red-Green-Blue (RGB) color model color object. For most
consumer-grade devices (e.g., CRTs, LCDs, and printers), as
Expand Down Expand Up @@ -400,7 +400,7 @@ def __init__(self, r='#0000ff', g=None, b=None, space='rgb'):
else:
self._rgb = rgbcolor((r, g, b), space=space)

def __repr__(self):
def __repr__(self) -> str:
"""
Return a string representation of this color.

Expand All @@ -415,7 +415,7 @@ def __repr__(self):
"""
return f"RGB color {self._rgb}"

def __lt__(self, right):
def __lt__(self, right) -> bool:
"""
Check whether a :class:`Color` object is less than some other
object. This doesn't make sense, and so we conclude that it is
Expand All @@ -438,7 +438,7 @@ def __lt__(self, right):
"""
return False

def __le__(self, right):
def __le__(self, right) -> bool:
"""
Check whether a :class:`Color` object is less than or equal to
some other object. It wouldn't make sense for it to be less than
Expand All @@ -462,7 +462,7 @@ def __le__(self, right):
"""
return self == right

def __eq__(self, right):
def __eq__(self, right) -> bool:
"""
Compare two :class:`Color` objects to determine whether
they refer to the same color.
Expand All @@ -489,7 +489,7 @@ def __eq__(self, right):
return self._rgb == right._rgb
return False

def __ne__(self, right):
def __ne__(self, right) -> bool:
"""
Compare two :class:`Color` objects to determine whether
they refer to different colors.
Expand All @@ -516,7 +516,7 @@ def __ne__(self, right):
"""
return not (self == right)

def __gt__(self, right):
def __gt__(self, right) -> bool:
"""
Check whether a :class:`Color` object is greater than some other
object. This doesn't make sense, and so we conclude that it is
Expand All @@ -539,7 +539,7 @@ def __gt__(self, right):
"""
return False

def __ge__(self, right):
def __ge__(self, right) -> bool:
"""
Check whether a :class:`Color` object is greater than or equal
to some other object. It wouldn't make sense for it to be
Expand All @@ -563,7 +563,7 @@ def __ge__(self, right):
"""
return self == right

def __hash__(self):
def __hash__(self) -> int:
"""
Return the hash value of a color.
Equal colors return equal hash values.
Expand Down Expand Up @@ -1004,7 +1004,7 @@ class ColorsDict(dict):
sage: sorted(colors)
['aliceblue', 'antiquewhite', 'aqua', 'aquamarine', ...]
"""
def __init__(self):
def __init__(self) -> None:
"""
Construct a dict-like collection of colors. The keys are the
color names (i.e., strings) and the values are RGB 3-tuples of
Expand Down Expand Up @@ -1364,7 +1364,7 @@ class Colormaps(MutableMapping):
sage: sorted(colormaps)
['Accent', ...]
"""
def __init__(self):
def __init__(self) -> None:
"""
Construct an empty mutable collection of color maps.

Expand Down Expand Up @@ -1418,7 +1418,7 @@ def __dir__(self):
'__setitem__', '__delitem__']
return dir(super()) + methods + sorted(self)

def __len__(self):
def __len__(self) -> int:
"""
Return the number of color maps.

Expand Down Expand Up @@ -1452,7 +1452,7 @@ def __iter__(self):
self.load_maps()
return iter(self.maps)

def __contains__(self, name):
def __contains__(self, name) -> bool:
"""
Return whether a map is in the color maps collection.

Expand Down Expand Up @@ -1536,7 +1536,7 @@ def __getattr__(self, name):
except KeyError:
raise AttributeError("'{}' has no attribute or colormap {}".format(type(self).__name__, name))

def __repr__(self):
def __repr__(self) -> str:
"""
Return a string representation of the color map collection.

Expand Down
8 changes: 4 additions & 4 deletions src/sage/schemes/elliptic_curves/ell_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class EllipticCurve_generic(WithEqualityById, plane_curve.ProjectivePlaneCurve):
sage: -5*P
(179051/80089 : -91814227/22665187 : 1)
"""
def __init__(self, K, ainvs, category=None):
def __init__(self, K, ainvs, category=None) -> None:
r"""
Construct an elliptic curve from Weierstrass `a`-coefficients.

Expand Down Expand Up @@ -465,7 +465,7 @@ def _symbolic_(self, SR):
x, y = SR.var('x, y')
return y**2 + a[0]*x*y + a[2]*y == x**3 + a[1]*x**2 + a[3]*x + a[4]

def __contains__(self, P):
def __contains__(self, P) -> bool:
"""
Return ``True`` if and only if P is a point on the elliptic curve.

Expand Down Expand Up @@ -1049,7 +1049,7 @@ def __getitem__(self, n):
"""
raise NotImplementedError("not implemented.")

def __is_over_RationalField(self):
def __is_over_RationalField(self) -> bool:
r"""
Internal function. Return true iff the base ring of this elliptic
curve is the field of rational numbers.
Expand All @@ -1065,7 +1065,7 @@ def __is_over_RationalField(self):
"""
return isinstance(self.base_ring(), RationalField)

def is_on_curve(self, x, y):
def is_on_curve(self, x, y) -> bool:
r"""
Return ``True`` if `(x,y)` is an affine point on this curve.

Expand Down
Loading
Loading