Skip to content
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
1 change: 0 additions & 1 deletion src/sage/structure/element.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ cdef bin_op_exception(op, x, y)
cdef class Element(SageObject):
cdef Parent _parent
cpdef _richcmp_(left, right, int op)
cpdef int _cmp_(left, right) except -2
cpdef base_extend(self, R)

cdef getattr_from_category(self, name)
Expand Down
7 changes: 0 additions & 7 deletions src/sage/structure/element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1159,13 +1159,6 @@ cdef class Element(SageObject):
return True
return NotImplemented

cpdef int _cmp_(left, right) except -2:
"""
This was the old comparison framework. Now deprecated. Do not use.
"""
deprecation(30130, "please use _richcmp_ for comparison methods")
raise NotImplementedError("__cmp__ and _cmp_ are deprecated")

##################################################
# Arithmetic using the coercion model
##################################################
Expand Down
38 changes: 10 additions & 28 deletions src/sage/structure/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def __bool__(self) -> bool:
"""
return bool(self._options[self._name])

def __call__(self, *args, **kwds):
def __call__(self, *args):
r"""
Get or set value of the option ``self``.

Expand Down Expand Up @@ -662,38 +662,20 @@ def __call__(self, *args, **kwds):
True
sage: config._reset()

Check the deprecation::
Check the input::

sage: config.size(value=None)
doctest:...: DeprecationWarning: keyword argument "value" should be replaced by positional argument
See https://github.com/sagemath/sage/issues/30763 for details.
sage: config.size() is None
True
sage: config.size(1, 2)
Traceback (most recent call last):
...
TypeError: option takes at most one argument "value"
sage: config.size(unknown=3)
Traceback (most recent call last):
...
TypeError: option takes at most one argument "value"
sage: config.size(4, value=5)
Traceback (most recent call last):
...
TypeError: option takes at most one argument "value"
TypeError: option takes at most one argument
"""
if not args and not kwds:
if not args:
return self._options[self._name]
if 'value' in kwds:
from sage.misc.superseded import deprecation
deprecation(30763, 'keyword argument "value" should be replaced '
'by positional argument')
args += (kwds.pop('value'),)
if len(args) > 1 or kwds:
raise TypeError('option takes at most one argument "value"')
if len(args) > 1:
raise TypeError('option takes at most one argument')
self._options[self._name] = args[0]

def __eq__(self, other):
def __eq__(self, other) -> bool:
r"""
Equality testing for an option in based on the value of the attribute.

Expand All @@ -708,7 +690,7 @@ def __eq__(self, other):
"""
return self._options[self._name] == other

def __ne__(self, other):
def __ne__(self, other) -> bool:
r"""
Inequality testing for an option in based on the value of
the attribute.
Expand All @@ -724,7 +706,7 @@ def __ne__(self, other):
"""
return self._options[self._name] != other

def __hash__(self):
def __hash__(self) -> int:
r"""
Return the hash of ``self``, which is the hash of the corresponding
value.
Expand All @@ -736,7 +718,7 @@ def __hash__(self):
"""
return hash(self._options[self._name])

def __str__(self):
def __str__(self) -> str:
r"""
Return the string representation of ``self``, which is the string of
the corresponding value.
Expand Down
25 changes: 5 additions & 20 deletions src/sage/structure/support_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
r"""
Iterable of the keys of a Mapping associated with nonzero values
"""

from collections.abc import MappingView, Sequence, Set

from sage.misc.superseded import deprecation


class SupportView(MappingView, Sequence, Set):
r"""
Expand Down Expand Up @@ -49,7 +46,7 @@ class SupportView(MappingView, Sequence, Set):
3
"""

def __init__(self, mapping, *, zero=None):
def __init__(self, mapping, *, zero=None) -> None:
r"""
TESTS::

Expand All @@ -61,7 +58,7 @@ def __init__(self, mapping, *, zero=None):
self._mapping = mapping
self._zero = zero

def __len__(self):
def __len__(self) -> int:
r"""
TESTS::

Expand Down Expand Up @@ -120,7 +117,7 @@ def __iter__(self):
if value != zero:
yield key

def __contains__(self, key):
def __contains__(self, key) -> bool:
r"""
TESTS::

Expand Down Expand Up @@ -149,14 +146,8 @@ def __eq__(self, other):
sage: supp = SupportView(d); supp
SupportView({1: 17, 2: 0})
sage: supp == [1]
doctest:warning...
DeprecationWarning: comparing a SupportView with a list is deprecated
See https://github.com/sagemath/sage/issues/34509 for details.
True
False
"""
if isinstance(other, list):
deprecation(34509, 'comparing a SupportView with a list is deprecated')
return list(self) == other
return NotImplemented

def __ne__(self, other):
Expand All @@ -168,12 +159,6 @@ def __ne__(self, other):
sage: supp = SupportView(d); supp
SupportView({1: 17, 2: 0})
sage: supp != [1]
doctest:warning...
DeprecationWarning: comparing a SupportView with a list is deprecated
See https://github.com/sagemath/sage/issues/34509 for details.
False
True
"""
if isinstance(other, list):
deprecation(34509, 'comparing a SupportView with a list is deprecated')
return list(self) != other
return NotImplemented
Loading