diff --git a/src/sage/algebras/shuffle_algebra.py b/src/sage/algebras/shuffle_algebra.py index adee056035c..aea170d2295 100644 --- a/src/sage/algebras/shuffle_algebra.py +++ b/src/sage/algebras/shuffle_algebra.py @@ -439,7 +439,7 @@ def _element_constructor_(self, x): if isinstance(P, ShuffleAlgebra): if P is self: return x - if not (P is self.base_ring()): + if P is not self.base_ring(): return self.element_class(self, x.monomial_coefficients()) if isinstance(P, DualPBWBasis): return self(P.expansion(x)) diff --git a/src/sage/crypto/block_cipher/miniaes.py b/src/sage/crypto/block_cipher/miniaes.py index 0a421c17e5e..cf591029d80 100644 --- a/src/sage/crypto/block_cipher/miniaes.py +++ b/src/sage/crypto/block_cipher/miniaes.py @@ -1642,7 +1642,7 @@ def GF_to_binary(self, G): return B(S) # G is a matrix over GF(16) elif isinstance(G, Matrix_dense): - if not (G.base_ring() is K): + if G.base_ring() is not K: raise TypeError("input G must be an element of GF(16), a list of elements of GF(16), or a matrix over GF(16)") S = "".join(str(self._GF_to_bin[G[i][j]]) for i in range(G.nrows()) for j in range(G.ncols())) @@ -1772,7 +1772,7 @@ def GF_to_integer(self, G): return [self._GF_to_int[g] for g in G] # G is a matrix over GF(16) elif isinstance(G, Matrix_dense): - if not (G.base_ring() is K): + if G.base_ring() is not K: raise TypeError("input G must be an element of GF(16), a list of elements of GF(16), or a matrix over GF(16)") return [self._GF_to_int[G[i][j]] for i in range(G.nrows()) for j in range(G.ncols())] # the type of G doesn't match the supported types diff --git a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py index f84ab7e94ed..9734b3767ac 100644 --- a/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py +++ b/src/sage/dynamics/arithmetic_dynamics/berkovich_ds.py @@ -703,7 +703,7 @@ def conjugate(self, M, adjugate=False, new_ideal=None): new_system = self._system.conjugate(M, adjugate=adjugate) system_domain = new_system.domain() if new_ideal is None: - if not system_domain.base_ring() is QQ: + if system_domain.base_ring() is not QQ: new_ideal = system_domain.base_ring().prime_above(self.domain().ideal()) else: new_ideal = self.domain().ideal() diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 4eced79fe9b..c2e2393eaef 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -2695,7 +2695,7 @@ def is_perfect(self, certificate=False): return True if not certificate else None answer = self.is_odd_hole_free(certificate=certificate) - if not (answer is True): + if answer is not True: return answer return self_complement.is_odd_hole_free(certificate=certificate) diff --git a/src/sage/groups/abelian_gps/abelian_aut.py b/src/sage/groups/abelian_gps/abelian_aut.py index 89551916589..c58eebc4b4f 100644 --- a/src/sage/groups/abelian_gps/abelian_aut.py +++ b/src/sage/groups/abelian_gps/abelian_aut.py @@ -404,7 +404,7 @@ def is_subgroup_of(self, G): """ if not isinstance(G, AbelianGroupAutomorphismGroup_gap): raise ValueError("input must be an instance of AbelianGroup_gap") - if not self.ambient() is G.ambient(): + if self.ambient() is not G.ambient(): return False return G.gap().IsSubsemigroup(self).sage() diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py index 0c0d6a5f49b..eb41bbd8320 100644 --- a/src/sage/groups/abelian_gps/abelian_group_gap.py +++ b/src/sage/groups/abelian_gps/abelian_group_gap.py @@ -533,7 +533,7 @@ def is_subgroup_of(self, G): """ if not isinstance(G, AbelianGroup_gap): raise ValueError("input must be an instance of AbelianGroup_gap") - if not self.ambient() is G.ambient(): + if self.ambient() is not G.ambient(): return False return G.gap().IsSubsemigroup(self).sage() diff --git a/src/sage/groups/affine_gps/group_element.py b/src/sage/groups/affine_gps/group_element.py index fff5881868f..b1e3cd1e0cb 100644 --- a/src/sage/groups/affine_gps/group_element.py +++ b/src/sage/groups/affine_gps/group_element.py @@ -132,9 +132,9 @@ def __init__(self, parent, A, b=0, convert=True, check=True): # Note: the coercion framework expects that we raise TypeError for invalid input if not isinstance(A, Matrix): raise TypeError('A must be a matrix') - if not (A.parent() is parent.matrix_space()): + if A.parent() is not parent.matrix_space(): raise TypeError('A must be an element of ' + str(parent.matrix_space())) - if not (b.parent() is parent.vector_space()): + if b.parent() is not parent.vector_space(): raise TypeError('b must be an element of ' + str(parent.vector_space())) parent._element_constructor_check(A, b) super().__init__(parent) diff --git a/src/sage/interfaces/psage.py b/src/sage/interfaces/psage.py index 96d4233bbeb..9fba3d1d015 100644 --- a/src/sage/interfaces/psage.py +++ b/src/sage/interfaces/psage.py @@ -122,7 +122,7 @@ def __del__(self): except OSError: pass - if not (self._expect is None): + if self._expect is not None: cmd = 'kill -9 %s' % self._expect.pid os.system(cmd) diff --git a/src/sage/logic/boolformula.py b/src/sage/logic/boolformula.py index d22c0443461..b496bb91158 100644 --- a/src/sage/logic/boolformula.py +++ b/src/sage/logic/boolformula.py @@ -1106,7 +1106,7 @@ def convert_opt(self, tree): :func:`~sage.logic.logicparser.apply_func()` in :mod:`~sage.logic.logicparser`. """ - if not isinstance(tree[1], tuple) and not (tree[1] is None): + if not isinstance(tree[1], tuple) and tree[1] is not None: lval = ('prop', tree[1]) else: lval = tree[1] diff --git a/src/sage/misc/rest_index_of_methods.py b/src/sage/misc/rest_index_of_methods.py index 0d1d46f63b7..e7d4ca448ff 100644 --- a/src/sage/misc/rest_index_of_methods.py +++ b/src/sage/misc/rest_index_of_methods.py @@ -275,7 +275,7 @@ def local_filter(f, name): else: return not any(hasattr(s, name) for s in superclasses) else: - return inspect.isclass(root) or not (f is gen_rest_table_index) + return inspect.isclass(root) or f is not gen_rest_table_index def can_import(f): # poke it to provoke a lazy import to resolve diff --git a/src/sage/modules/fp_graded/morphism.py b/src/sage/modules/fp_graded/morphism.py index 890178110a6..5f3c9e461c6 100755 --- a/src/sage/modules/fp_graded/morphism.py +++ b/src/sage/modules/fp_graded/morphism.py @@ -1138,7 +1138,7 @@ def lift(self, f, verbose=False): M = f.domain() # It is an error to call this function with incompatible arguments. - if not f.codomain() is N: + if f.codomain() is not N: raise ValueError('the codomains of this homomorphism and the homomorphism ' 'we are lifting over are different') diff --git a/src/sage/rings/finite_rings/galois_group.py b/src/sage/rings/finite_rings/galois_group.py index 1cdd70fcbb2..880aea93c76 100644 --- a/src/sage/rings/finite_rings/galois_group.py +++ b/src/sage/rings/finite_rings/galois_group.py @@ -142,7 +142,7 @@ def _element_constructor_(self, x, check=True): else: raise RuntimeError("Automorphism was not a power of Frobenius") elif isinstance(x, FrobeniusEndomorphism_finite_field): - if check and not x.domain() is k: + if check and x.domain() is not k: raise ValueError("Not an automorphism of the correct finite field") n = x.power() elif isinstance(x, list) and len(x) == 1 and x[0] in ZZ: diff --git a/src/sage/rings/invariants/invariant_theory.py b/src/sage/rings/invariants/invariant_theory.py index fb953f98813..c2e80fbe633 100644 --- a/src/sage/rings/invariants/invariant_theory.py +++ b/src/sage/rings/invariants/invariant_theory.py @@ -286,7 +286,7 @@ def diff(j): dg = g.form().derivative(x,h-j).derivative(y,j) return (-1)**j * binomial(h,j) * df * dg tv = scalar * sum([diff(j) for j in range(h+1)]) - if not tv.parent() is R: + if tv.parent() is not R: S = tv.parent() x = S(x) y = S(y) diff --git a/src/sage/rings/localization.py b/src/sage/rings/localization.py index be1fc217a8d..ab6916d36c8 100644 --- a/src/sage/rings/localization.py +++ b/src/sage/rings/localization.py @@ -685,9 +685,9 @@ def __init__(self, base_ring, extra_units, names=None, normalize=True, category= sage: L = R.localization(x**2 + 1) # needs sage.libs.pari sage: TestSuite(L).run() """ - if type(extra_units) is tuple: + if isinstance(extra_units, tuple): extra_units = list(extra_units) - if not type(extra_units) is list: + elif not isinstance(extra_units, list): extra_units = [extra_units] from sage.rings.polynomial.laurent_polynomial_ring_base import LaurentPolynomialRing_generic diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py index 315e31cf42f..7128d40032e 100644 --- a/src/sage/rings/number_field/number_field.py +++ b/src/sage/rings/number_field/number_field.py @@ -10415,7 +10415,7 @@ def hilbert_symbol_negative_at_S(self, S, b, check=True): from sage.groups.additive_abelian.additive_abelian_group import AdditiveAbelianGroup # input checks - if not type(S) is list: + if not isinstance(S, list): raise TypeError("first argument must be a list") if b not in self: raise TypeError("second argument must be an element of this field") diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py index 6c4ec02c1b1..6ffe1353fc9 100644 --- a/src/sage/rings/polynomial/multi_polynomial_element.py +++ b/src/sage/rings/polynomial/multi_polynomial_element.py @@ -688,7 +688,7 @@ def degree(self, x=None, std_grading=False): return Integer(self.element().degree(None)) return self.weighted_degree(self.parent().term_order().weights()) if isinstance(x, MPolynomial): - if not x.parent() is self.parent(): + if x.parent() is not self.parent(): try: x = self.parent().coerce(x) except TypeError: diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py index 8e358652be3..4352d9efbac 100644 --- a/src/sage/rings/polynomial/multi_polynomial_ideal.py +++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py @@ -638,7 +638,7 @@ def _singular_(self, singular=None): try: self.ring()._singular_(singular).set_ring() I = self.__singular - if not (I.parent() is singular): + if I.parent() is not singular: raise ValueError I._check_valid() return I diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py index 027a8997067..9851c477abf 100644 --- a/src/sage/rings/polynomial/polynomial_quotient_ring.py +++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py @@ -216,7 +216,7 @@ def create_key(self, ring, polynomial, names=None): raise TypeError("ring must be a polynomial ring") if not isinstance(polynomial, polynomial_element.Polynomial): raise TypeError("must be a polynomial") - if not polynomial.parent() is ring: + if polynomial.parent() is not ring: raise TypeError("polynomial must be in ring") c = polynomial.leading_coefficient() diff --git a/src/sage/rings/valuation/gauss_valuation.py b/src/sage/rings/valuation/gauss_valuation.py index ca67b25274e..0e867e0a2f5 100644 --- a/src/sage/rings/valuation/gauss_valuation.py +++ b/src/sage/rings/valuation/gauss_valuation.py @@ -97,7 +97,7 @@ def create_key(self, domain, v=None): if v is None: v = domain.base_ring().valuation() - if not v.domain() is domain.base_ring(): + if v.domain() is not domain.base_ring(): raise ValueError("the domain of v must be the base ring of domain but %r is not defined over %r but over %r" % (v, domain.base_ring(), v.domain())) if not v.is_discrete_valuation(): raise ValueError("v must be a discrete valuation but %r is not" % (v,))