Skip to content

Commit 1039d66

Browse files
author
Release Manager
committed
gh-36032: Fix pycodestyle warning E721 <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> Fix the warnings coming from pycodestyle E721, "E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`". <!-- Describe your changes here in detail --> Mostly I've made changes like `type(x) == type(y)` to `type(x) is type(y)`, also adding some uses of `isinstance`. When I run `pycodestyle --select=E721 --statistics src/sage/` I now get no hits. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [X] The title is concise, informative, and self-explanatory. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #36032 Reported by: John H. Palmieri Reviewer(s): Matthias Köppe
2 parents ad549b6 + 3ceb31e commit 1039d66

33 files changed

+47
-47
lines changed

src/sage/algebras/hecke_algebras/cubic_hecke_base_ring.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def normalize_names_markov(names, markov_trace_version):
5959
if markov_trace_version:
6060
names = normalize_names(4, names)
6161
else:
62-
if type(names) == tuple:
62+
if isinstance(names, tuple):
6363
names = list(names)
64-
if type(names) == list and len(names) > 3:
64+
if isinstance(names, list) and len(names) > 3:
6565
names = normalize_names(3, names[0:3])
6666
else:
6767
names = normalize_names(3, names)
@@ -641,10 +641,10 @@ def create_specialization(self, im_cubic_equation_roots, im_writhe_parameter=Non
641641
# corresponding specialized extension ring.
642642
# ----------------------------------------------------------------------
643643

644-
if type(im_cubic_equation_roots) == tuple:
644+
if isinstance(im_cubic_equation_roots, tuple):
645645
im_cubic_equation_roots = list(im_cubic_equation_roots)
646646

647-
if type(im_cubic_equation_roots) != list:
647+
if not isinstance(im_cubic_equation_roots, list):
648648
raise TypeError('cubic_equation_roots must be a list of three elements')
649649

650650
if len(im_cubic_equation_roots) != 3:
@@ -1226,10 +1226,10 @@ def create_specialization(self, im_cubic_equation_parameters, im_writhe_paramete
12261226
# ----------------------------------------------------------------------
12271227
# setting the base_ring according to the cubic_equation_parameters
12281228
# ----------------------------------------------------------------------
1229-
if type(im_cubic_equation_parameters) == tuple:
1229+
if isinstance(im_cubic_equation_parameters, tuple):
12301230
im_cubic_equation_parameters = list(im_cubic_equation_parameters)
12311231

1232-
if type(im_cubic_equation_parameters) != list:
1232+
if not isinstance(im_cubic_equation_parameters, list):
12331233
raise TypeError('cubic_equation_parameters must be a list of three elements')
12341234

12351235
if len(im_cubic_equation_parameters) != 3:

src/sage/algebras/quantum_groups/quantum_group_gap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ def __richcmp__(self, other, op):
11611161
False
11621162
"""
11631163
if op == op_EQ:
1164-
return (type(self) == type(other)
1164+
return (type(self) is type(other)
11651165
and self.domain() is other.domain()
11661166
and self._im_gens == other._im_gens)
11671167
if op == op_NE:

src/sage/categories/pushout.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def __eq__(self, other):
202202
sage: I == I # indirect doctest
203203
True
204204
"""
205-
return type(self) == type(other)
205+
return type(self) is type(other)
206206

207207
def __ne__(self, other):
208208
"""
@@ -525,7 +525,7 @@ def __eq__(self, other):
525525
if isinstance(other, CompositeConstructionFunctor):
526526
return self.all == other.all
527527
else:
528-
return type(self) == type(other)
528+
return type(self) is type(other)
529529

530530
def __ne__(self, other):
531531
"""
@@ -677,7 +677,7 @@ def __eq__(self, other):
677677
sage: I == QQ.construction()[0]
678678
False
679679
"""
680-
c = (type(self) == type(other))
680+
c = (type(self) is type(other))
681681
if not c:
682682
if isinstance(other, IdentityFunctor_generic):
683683
return True
@@ -2986,7 +2986,7 @@ def __eq__(self, other):
29862986
"""
29872987
if not isinstance(other, QuotientFunctor):
29882988
return False
2989-
return (type(self) == type(other) and
2989+
return (type(self) is type(other) and
29902990
self.domain() == other.domain() and
29912991
self.codomain() == other.codomain() and
29922992
self.names == other.names and

src/sage/combinat/growth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ def __eq__(self, other):
11281128
sage: G1 == G2
11291129
False
11301130
"""
1131-
return (type(self) == type(other) and
1131+
return (type(self) is type(other) and
11321132
self.rule == other.rule and
11331133
self._lambda == other._lambda and
11341134
self._mu == other._mu and

src/sage/combinat/recognizable_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2095,7 +2095,7 @@ def _element_constructor_(self, data,
20952095
if isinstance(data, int) and data == 0:
20962096
return self._zero_()
20972097

2098-
if type(data) == self.element_class and data.parent() == self:
2098+
if isinstance(data, self.element_class) and data.parent() == self:
20992099
element = data
21002100

21012101
elif isinstance(data, RecognizableSeries):

src/sage/combinat/words/paths.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def __eq__(self, other):
455455
sage: W1 == W3
456456
False
457457
"""
458-
return self is other or (type(self) == type(other) and
458+
return self is other or (type(self) is type(other) and
459459
self.alphabet() == other.alphabet() and
460460
self.vector_space() == other.vector_space() and
461461
self.letters_to_steps() == other.letters_to_steps())

src/sage/doctest/sources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def __eq__(self, other):
159159
sage: FDS == FDS2
160160
True
161161
"""
162-
if type(self) != type(other):
162+
if type(self) is not type(other):
163163
return False
164164
return self.__dict__ == other.__dict__
165165

src/sage/dynamics/complex_dynamics/mandel_julia.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def external_ray(theta, **kwds):
396396
pixel[i, j] = old_pixel[i, j]
397397

398398
# Make sure that theta is a list so loop below works
399-
if type(theta) != list:
399+
if not isinstance(theta, list):
400400
theta = [theta]
401401

402402
# Check if theta is in the interval [0,1]

src/sage/geometry/cone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ def __richcmp__(self, right, op):
844844
sage: c2 is c3
845845
False
846846
"""
847-
if type(self) != type(right):
847+
if type(self) is not type(right):
848848
return NotImplemented
849849

850850
# We probably do need to have explicit comparison of lattices here

src/sage/geometry/relative_interior.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def __eq__(self, other):
337337
sage: ri_segment == empty
338338
False
339339
"""
340-
if type(self) != type(other):
340+
if type(self) is not type(other):
341341
return False
342342
return self._polyhedron == other._polyhedron
343343

0 commit comments

Comments
 (0)