Skip to content

Commit a4da532

Browse files
committed
removed some deprecations in structure
1 parent 83b52a7 commit a4da532

File tree

2 files changed

+15
-48
lines changed

2 files changed

+15
-48
lines changed

src/sage/structure/global_options.py

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def __bool__(self) -> bool:
632632
"""
633633
return bool(self._options[self._name])
634634

635-
def __call__(self, *args, **kwds):
635+
def __call__(self, *args):
636636
r"""
637637
Get or set value of the option ``self``.
638638
@@ -662,38 +662,20 @@ def __call__(self, *args, **kwds):
662662
True
663663
sage: config._reset()
664664
665-
Check the deprecation::
665+
Check the input::
666666
667-
sage: config.size(value=None)
668-
doctest:...: DeprecationWarning: keyword argument "value" should be replaced by positional argument
669-
See https://github.com/sagemath/sage/issues/30763 for details.
670-
sage: config.size() is None
671-
True
672667
sage: config.size(1, 2)
673668
Traceback (most recent call last):
674669
...
675-
TypeError: option takes at most one argument "value"
676-
sage: config.size(unknown=3)
677-
Traceback (most recent call last):
678-
...
679-
TypeError: option takes at most one argument "value"
680-
sage: config.size(4, value=5)
681-
Traceback (most recent call last):
682-
...
683-
TypeError: option takes at most one argument "value"
670+
TypeError: option takes at most one argument
684671
"""
685-
if not args and not kwds:
672+
if not args:
686673
return self._options[self._name]
687-
if 'value' in kwds:
688-
from sage.misc.superseded import deprecation
689-
deprecation(30763, 'keyword argument "value" should be replaced '
690-
'by positional argument')
691-
args += (kwds.pop('value'),)
692-
if len(args) > 1 or kwds:
693-
raise TypeError('option takes at most one argument "value"')
674+
if len(args) > 1:
675+
raise TypeError('option takes at most one argument')
694676
self._options[self._name] = args[0]
695677

696-
def __eq__(self, other):
678+
def __eq__(self, other) -> bool:
697679
r"""
698680
Equality testing for an option in based on the value of the attribute.
699681
@@ -708,7 +690,7 @@ def __eq__(self, other):
708690
"""
709691
return self._options[self._name] == other
710692

711-
def __ne__(self, other):
693+
def __ne__(self, other) -> bool:
712694
r"""
713695
Inequality testing for an option in based on the value of
714696
the attribute.
@@ -724,7 +706,7 @@ def __ne__(self, other):
724706
"""
725707
return self._options[self._name] != other
726708

727-
def __hash__(self):
709+
def __hash__(self) -> int:
728710
r"""
729711
Return the hash of ``self``, which is the hash of the corresponding
730712
value.
@@ -736,7 +718,7 @@ def __hash__(self):
736718
"""
737719
return hash(self._options[self._name])
738720

739-
def __str__(self):
721+
def __str__(self) -> str:
740722
r"""
741723
Return the string representation of ``self``, which is the string of
742724
the corresponding value.

src/sage/structure/support_view.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
r"""
33
Iterable of the keys of a Mapping associated with nonzero values
44
"""
5-
65
from collections.abc import MappingView, Sequence, Set
76

8-
from sage.misc.superseded import deprecation
9-
107

118
class SupportView(MappingView, Sequence, Set):
129
r"""
@@ -49,7 +46,7 @@ class SupportView(MappingView, Sequence, Set):
4946
3
5047
"""
5148

52-
def __init__(self, mapping, *, zero=None):
49+
def __init__(self, mapping, *, zero=None) -> None:
5350
r"""
5451
TESTS::
5552
@@ -61,7 +58,7 @@ def __init__(self, mapping, *, zero=None):
6158
self._mapping = mapping
6259
self._zero = zero
6360

64-
def __len__(self):
61+
def __len__(self) -> int:
6562
r"""
6663
TESTS::
6764
@@ -120,7 +117,7 @@ def __iter__(self):
120117
if value != zero:
121118
yield key
122119

123-
def __contains__(self, key):
120+
def __contains__(self, key) -> bool:
124121
r"""
125122
TESTS::
126123
@@ -149,14 +146,8 @@ def __eq__(self, other):
149146
sage: supp = SupportView(d); supp
150147
SupportView({1: 17, 2: 0})
151148
sage: supp == [1]
152-
doctest:warning...
153-
DeprecationWarning: comparing a SupportView with a list is deprecated
154-
See https://github.com/sagemath/sage/issues/34509 for details.
155-
True
149+
False
156150
"""
157-
if isinstance(other, list):
158-
deprecation(34509, 'comparing a SupportView with a list is deprecated')
159-
return list(self) == other
160151
return NotImplemented
161152

162153
def __ne__(self, other):
@@ -168,12 +159,6 @@ def __ne__(self, other):
168159
sage: supp = SupportView(d); supp
169160
SupportView({1: 17, 2: 0})
170161
sage: supp != [1]
171-
doctest:warning...
172-
DeprecationWarning: comparing a SupportView with a list is deprecated
173-
See https://github.com/sagemath/sage/issues/34509 for details.
174-
False
162+
True
175163
"""
176-
if isinstance(other, list):
177-
deprecation(34509, 'comparing a SupportView with a list is deprecated')
178-
return list(self) != other
179164
return NotImplemented

0 commit comments

Comments
 (0)