From 8145739bb4efb4a04c4a070e1d782c812cfae3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 15 Oct 2023 09:37:35 +0200 Subject: [PATCH] using ruff for UP004, UP008, UP028 --- src/sage/algebras/free_algebra_quotient.py | 2 +- src/sage/categories/enumerated_sets.py | 6 ++---- src/sage/categories/finite_enumerated_sets.py | 3 +-- src/sage/categories/posets.py | 3 +-- src/sage/coding/guruswami_sudan/interpolation.py | 3 +-- src/sage/combinat/abstract_tree.py | 3 +-- src/sage/combinat/alternating_sign_matrix.py | 3 +-- .../combinat/cluster_algebra_quiver/cluster_seed.py | 3 +-- src/sage/combinat/colored_permutations.py | 4 ++-- src/sage/combinat/combinat.py | 6 ++---- src/sage/combinat/designs/design_catalog.py | 2 +- src/sage/combinat/finite_state_machine.py | 6 ++---- src/sage/combinat/free_module.py | 4 ++-- src/sage/combinat/integer_matrices.py | 2 +- src/sage/combinat/integer_vector_weighted.py | 2 +- src/sage/combinat/k_tableau.py | 6 ++---- src/sage/combinat/lr_tableau.py | 4 ++-- src/sage/combinat/plane_partition.py | 2 +- src/sage/combinat/posets/posets.py | 4 ++-- src/sage/combinat/recognizable_series.py | 6 +++--- src/sage/combinat/regular_sequence.py | 4 ++-- src/sage/combinat/ribbon_shaped_tableau.py | 4 ++-- .../combinat/rigged_configurations/kleber_tree.py | 12 +++++------- .../combinat/rigged_configurations/kr_tableaux.py | 2 +- .../combinat/rigged_configurations/rc_crystal.py | 2 +- .../combinat/rigged_configurations/rc_infinity.py | 6 +++--- .../rigged_configurations/rigged_configurations.py | 8 ++++---- .../tensor_product_kr_tableaux.py | 7 +++---- src/sage/combinat/root_system/type_relabel.py | 2 +- src/sage/combinat/species/cycle_species.py | 2 +- src/sage/combinat/species/linear_order_species.py | 2 +- src/sage/combinat/species/partition_species.py | 2 +- src/sage/combinat/species/permutation_species.py | 2 +- src/sage/combinat/species/set_species.py | 2 +- src/sage/combinat/species/subset_species.py | 2 +- src/sage/combinat/tableau.py | 3 +-- src/sage/combinat/words/abstract_word.py | 6 ++---- src/sage/combinat/words/word_generators.py | 3 +-- src/sage/combinat/words/words.py | 3 +-- src/sage/cpython/_py2_random.py | 10 +++++----- src/sage/data_structures/mutable_poset.py | 13 +++++-------- src/sage/databases/stein_watkins.py | 3 +-- src/sage/doctest/forker.py | 2 +- src/sage/features/join_feature.py | 4 ++-- src/sage/functions/orthogonal_polys.py | 6 +++--- src/sage/functions/piecewise.py | 3 +-- src/sage/geometry/polyhedral_complex.py | 6 ++---- src/sage/geometry/polyhedron/base0.py | 6 ++---- src/sage/geometry/polyhedron/generating_function.py | 4 ++-- src/sage/geometry/polyhedron/plot.py | 3 +-- src/sage/geometry/triangulation/element.py | 3 +-- .../geometry/triangulation/point_configuration.py | 9 +++------ src/sage/graphs/generic_graph.py | 3 +-- src/sage/graphs/graph.py | 3 +-- src/sage/graphs/graph_generators.py | 6 ++---- src/sage/homology/chain_complex.py | 4 ++-- src/sage/homology/koszul_complex.py | 2 +- src/sage/interfaces/polymake.py | 4 ++-- src/sage/interfaces/r.py | 2 +- src/sage/interfaces/singular.py | 2 +- src/sage/matrix/compute_J_ideal.py | 2 +- src/sage/matrix/matrix_space.py | 3 +-- src/sage/misc/bindable_class.py | 2 +- src/sage/modules/free_module.py | 2 +- src/sage/rings/number_field/class_group.py | 3 +-- src/sage/rings/padics/padic_extension_generic.py | 2 +- src/sage/rings/padics/padic_extension_leaves.py | 2 +- src/sage/rings/padics/padic_valuation.py | 2 +- src/sage/schemes/projective/projective_morphism.py | 2 +- src/sage/schemes/projective/projective_subscheme.py | 2 +- src/sage/sets/family.py | 3 +-- src/sage/sets/set.py | 6 ++---- src/sage/tensor/modules/finite_rank_free_module.py | 2 +- src/sage/tensor/modules/free_module_basis.py | 2 +- src/sage/topology/simplicial_complex.py | 3 +-- 75 files changed, 119 insertions(+), 165 deletions(-) diff --git a/src/sage/algebras/free_algebra_quotient.py b/src/sage/algebras/free_algebra_quotient.py index 81c7f5ad91e..b19884335c4 100644 --- a/src/sage/algebras/free_algebra_quotient.py +++ b/src/sage/algebras/free_algebra_quotient.py @@ -65,7 +65,7 @@ from sage.structure.unique_representation import UniqueRepresentation -class FreeAlgebraQuotient(UniqueRepresentation, Algebra, object): +class FreeAlgebraQuotient(UniqueRepresentation, Algebra): @staticmethod def __classcall__(cls, A, mons, mats, names): """ diff --git a/src/sage/categories/enumerated_sets.py b/src/sage/categories/enumerated_sets.py index b0ea05d0563..8ae3270491c 100644 --- a/src/sage/categories/enumerated_sets.py +++ b/src/sage/categories/enumerated_sets.py @@ -313,8 +313,7 @@ def iterator_range(self, start=None, stop=None, step=None): if stop is None: if start is None: if step is None: - for x in self: - yield x + yield from self return start = 0 elif start < 0: @@ -793,8 +792,7 @@ def _iterator_from_list(self): sage: [next(it), next(it), next(it)] [1, 2, 3] """ - for x in self.tuple(): - yield x + yield from self.tuple() def _iterator_from_next(self): """ diff --git a/src/sage/categories/finite_enumerated_sets.py b/src/sage/categories/finite_enumerated_sets.py index 8a3c0e42ca5..4ca87850b7a 100644 --- a/src/sage/categories/finite_enumerated_sets.py +++ b/src/sage/categories/finite_enumerated_sets.py @@ -446,8 +446,7 @@ def iterator_range(self, start=None, stop=None, step=None): for j in range(stop): yield next(it) return - for x in self: - yield x + yield from self return if L is None: L = self.tuple() diff --git a/src/sage/categories/posets.py b/src/sage/categories/posets.py index 5cad3c70f73..98d1be6049d 100644 --- a/src/sage/categories/posets.py +++ b/src/sage/categories/posets.py @@ -150,8 +150,7 @@ def __iter__(self): from sage.combinat.posets.posets import FinitePosets_n n = 0 while True: - for P in FinitePosets_n(n): - yield P + yield from FinitePosets_n(n) n += 1 Finite = LazyImport('sage.categories.finite_posets', 'FinitePosets') diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py index 8625bae5b49..eea537a115a 100644 --- a/src/sage/coding/guruswami_sudan/interpolation.py +++ b/src/sage/coding/guruswami_sudan/interpolation.py @@ -46,8 +46,7 @@ def _flatten_once(lstlst): [1, 2, 3, 4, 5, 6] """ for lst in lstlst: - for e in lst: - yield e + yield from lst #************************************************************* # Linear algebraic Interpolation algorithm, helper functions diff --git a/src/sage/combinat/abstract_tree.py b/src/sage/combinat/abstract_tree.py index 1dd26c41222..ee797d990fa 100644 --- a/src/sage/combinat/abstract_tree.py +++ b/src/sage/combinat/abstract_tree.py @@ -779,8 +779,7 @@ def paths_at_depth(self, depth, path=[]): yield tuple(path) else: for i in range(len(self)): - for p in self[i].paths_at_depth(depth - 1, path + [i]): - yield p + yield from self[i].paths_at_depth(depth - 1, path + [i]) def node_number_at_depth(self, depth): r""" diff --git a/src/sage/combinat/alternating_sign_matrix.py b/src/sage/combinat/alternating_sign_matrix.py index ee34e183a70..e4eec5eedaf 100644 --- a/src/sage/combinat/alternating_sign_matrix.py +++ b/src/sage/combinat/alternating_sign_matrix.py @@ -1908,8 +1908,7 @@ def __iter__(self): [[1, 2, 3], [2, 3], [2]], [[1, 2, 3], [2, 3], [3]]] """ - for z in self._iterator_rec(self.n): - yield z + yield from self._iterator_rec(self.n) def _next_column_iterator(previous_column, height, i=None): diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py index 514acb43636..58fa26437fa 100644 --- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py @@ -3878,8 +3878,7 @@ def b_matrix_class_iter(self, depth=infinity, up_to_equivalence=True): ] """ Q = self.quiver() - for M in Q.mutation_class_iter(depth=depth, up_to_equivalence=up_to_equivalence, data_type='matrix'): - yield M + yield from Q.mutation_class_iter(depth=depth, up_to_equivalence=up_to_equivalence, data_type='matrix') def b_matrix_class(self, depth=infinity, up_to_equivalence=True): r""" diff --git a/src/sage/combinat/colored_permutations.py b/src/sage/combinat/colored_permutations.py index d97624a218d..ff9a67e3083 100644 --- a/src/sage/combinat/colored_permutations.py +++ b/src/sage/combinat/colored_permutations.py @@ -1557,7 +1557,7 @@ def _coerce_map_from_(self, C): [1 if v == 0 else -1 for v in x._colors], x._perm) - return super(SignedPermutations, self)._coerce_map_from_(C) + return super()._coerce_map_from_(C) def long_element(self, index_set=None): """ @@ -1587,7 +1587,7 @@ def long_element(self, index_set=None): True """ if index_set is not None: - return super(SignedPermutations, self).long_element() + return super().long_element() return self.element_class(self, [-ZZ.one()] * self._n, self._P.one()) def conjugacy_class_representative(self, nu): diff --git a/src/sage/combinat/combinat.py b/src/sage/combinat/combinat.py index 4b763bb5af8..4c182f7c0da 100644 --- a/src/sage/combinat/combinat.py +++ b/src/sage/combinat/combinat.py @@ -1938,8 +1938,7 @@ def __iterator_from_list(self) -> Iterator: sage: list(C) # indirect doctest [1, 2, 3] """ - for x in self.list(): - yield x + yield from self.list() def __iter__(self): """ @@ -2574,8 +2573,7 @@ def __iter__(self) -> Iterator: raise NotImplementedError i = 0 while True: - for c in finite(i): - yield c + yield from finite(i) i += 1 diff --git a/src/sage/combinat/designs/design_catalog.py b/src/sage/combinat/designs/design_catalog.py index 26b899cb93d..8bf7f14fd0b 100644 --- a/src/sage/combinat/designs/design_catalog.py +++ b/src/sage/combinat/designs/design_catalog.py @@ -118,4 +118,4 @@ 'OAMainFunctions', as_='orthogonal_arrays') lazy_import('sage.combinat.designs.gen_quadrangles_with_spread', - ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid')) \ No newline at end of file + ('generalised_quadrangle_with_spread', 'generalised_quadrangle_hermitian_with_ovoid')) diff --git a/src/sage/combinat/finite_state_machine.py b/src/sage/combinat/finite_state_machine.py index acd0adb2718..0d51f7c3774 100644 --- a/src/sage/combinat/finite_state_machine.py +++ b/src/sage/combinat/finite_state_machine.py @@ -5406,8 +5406,7 @@ def _iter_transitions_all_(self): [('1', '2'), ('2', '2')] """ for state in self.iter_states(): - for t in state.transitions: - yield t + yield from state.transitions def initial_states(self): """ @@ -6461,8 +6460,7 @@ def _iter_process_simple_(self, iterator): "here." % (len(branch.outputs),)) - for o in branch.outputs[0]: - yield o + yield from branch.outputs[0] branch.outputs[0] = [] # Reset output so that in the next round # (of "for current in iterator") only new diff --git a/src/sage/combinat/free_module.py b/src/sage/combinat/free_module.py index 2dce68651a2..14711e8713e 100644 --- a/src/sage/combinat/free_module.py +++ b/src/sage/combinat/free_module.py @@ -328,7 +328,7 @@ def __classcall_private__(cls, base_ring, basis_keys=None, category=None, latex_names = tuple(latex_names) keywords['latex_names'] = latex_names - return super(CombinatorialFreeModule, cls).__classcall__(cls, + return super().__classcall__(cls, base_ring, basis_keys, category=category, prefix=prefix, names=names, **keywords) @@ -1674,7 +1674,7 @@ def _coerce_map_from_(self, R): [vector_map[i](M.monomial(x[i])) for i, M in enumerate(modules)]), codomain=self) - return super(CombinatorialFreeModule_Tensor, self)._coerce_map_from_(R) + return super()._coerce_map_from_(R) class CartesianProductWithFlattening(): diff --git a/src/sage/combinat/integer_matrices.py b/src/sage/combinat/integer_matrices.py index 8d737c64349..238d0ef4091 100644 --- a/src/sage/combinat/integer_matrices.py +++ b/src/sage/combinat/integer_matrices.py @@ -77,7 +77,7 @@ def __classcall__(cls, row_sums, column_sums): from sage.combinat.composition import Composition row_sums = Composition(row_sums) column_sums = Composition(column_sums) - return super(IntegerMatrices, cls).__classcall__(cls, row_sums, column_sums) + return super().__classcall__(cls, row_sums, column_sums) def __init__(self, row_sums, column_sums): r""" diff --git a/src/sage/combinat/integer_vector_weighted.py b/src/sage/combinat/integer_vector_weighted.py index bd2198f29da..c7700671c61 100644 --- a/src/sage/combinat/integer_vector_weighted.py +++ b/src/sage/combinat/integer_vector_weighted.py @@ -101,7 +101,7 @@ def __classcall_private__(cls, n=None, weight=None): if n is None: return WeightedIntegerVectors_all(weight) - return super(WeightedIntegerVectors, cls).__classcall__(cls, n, weight) + return super().__classcall__(cls, n, weight) def __init__(self, n, weight): """ diff --git a/src/sage/combinat/k_tableau.py b/src/sage/combinat/k_tableau.py index 530f621ca31..0e4bbc41758 100644 --- a/src/sage/combinat/k_tableau.py +++ b/src/sage/combinat/k_tableau.py @@ -4104,8 +4104,7 @@ def __iter__(self): yield self([[None]*(row) for row in self._inner_shape]) else: for unT in StrongTableaux.standard_unmarked_iterator( self.k, size, self._outer_shape, self._inner_shape ): - for T in StrongTableaux.marked_given_unmarked_and_weight_iterator( unT, self.k, self._weight ): - yield T + yield from StrongTableaux.marked_given_unmarked_and_weight_iterator( unT, self.k, self._weight ) @classmethod def standard_unmarked_iterator( cls, k, size, outer_shape=None, inner_shape=[] ): @@ -4410,8 +4409,7 @@ def standard_marked_iterator( cls, k, size, outer_shape=None, inner_shape=[] ): [[]] """ for T in cls.standard_unmarked_iterator( k, size, outer_shape, inner_shape ): - for TT in cls.marked_given_unmarked_and_weight_iterator( T, k, [1]*(size) ): - yield TT + yield from cls.marked_given_unmarked_and_weight_iterator( T, k, [1]*(size) ) @classmethod def cells_head_dictionary( cls, T ): diff --git a/src/sage/combinat/lr_tableau.py b/src/sage/combinat/lr_tableau.py index c19effc2173..a94f576a134 100644 --- a/src/sage/combinat/lr_tableau.py +++ b/src/sage/combinat/lr_tableau.py @@ -174,7 +174,7 @@ def __classcall_private__(cls, shape, weight): weight = tuple(Partition(a) for a in weight) if shape.size() != sum(a.size() for a in weight): raise ValueError("the sizes of shapes and sequence of weights do not match") - return super(LittlewoodRichardsonTableaux, cls).__classcall__(cls, shape, weight) + return super().__classcall__(cls, shape, weight) def __init__(self, shape, weight): r""" @@ -193,7 +193,7 @@ def __init__(self, shape, weight): self._shape = shape self._weight = weight self._heights = [a.length() for a in self._weight] - super(LittlewoodRichardsonTableaux, self).__init__(category=FiniteEnumeratedSets()) + super().__init__(category=FiniteEnumeratedSets()) def _repr_(self): """ diff --git a/src/sage/combinat/plane_partition.py b/src/sage/combinat/plane_partition.py index 14d284b77c6..d18177aac00 100644 --- a/src/sage/combinat/plane_partition.py +++ b/src/sage/combinat/plane_partition.py @@ -1748,7 +1748,7 @@ def __init__(self, n): sage: TestSuite(PP).run() """ - super(PlanePartitions_n, self).__init__(category=FiniteEnumeratedSets()) + super().__init__(category=FiniteEnumeratedSets()) self._n = n def _repr_(self) -> str: diff --git a/src/sage/combinat/posets/posets.py b/src/sage/combinat/posets/posets.py index d3c46a1daf7..e223795099f 100644 --- a/src/sage/combinat/posets/posets.py +++ b/src/sage/combinat/posets/posets.py @@ -1319,7 +1319,7 @@ def __call__(self, element): """ if self._is_facade and element in self._element_to_vertex_dict: return element - return super(FinitePoset, self).__call__(element) + return super().__call__(element) def hasse_diagram(self): r""" @@ -8994,7 +8994,7 @@ def cardinality(self, from_iterator=False): if not from_iterator and self._n < len(known_values): return Integer(known_values[self._n]) else: - return super(FinitePosets_n, self).cardinality() + return super().cardinality() # For backward compatibility of pickles of the former Posets() diff --git a/src/sage/combinat/recognizable_series.py b/src/sage/combinat/recognizable_series.py index 698dd959619..173e061276b 100644 --- a/src/sage/combinat/recognizable_series.py +++ b/src/sage/combinat/recognizable_series.py @@ -455,7 +455,7 @@ def __init__(self, parent, mu, left, right): sage: S.mu[0] is M0, S.mu[1] is M1, S.left is L, S.right is R (True, True, True, True) """ - super(RecognizableSeries, self).__init__(parent=parent) + super().__init__(parent=parent) from copy import copy from sage.matrix.constructor import Matrix @@ -1660,7 +1660,7 @@ def __classcall__(cls, *args, **kwds): sage: Rec1 is Rec2 is Rec3 True """ - return super(RecognizableSeriesSpace, cls).__classcall__( + return super().__classcall__( cls, *cls.__normalize__(*args, **kwds)) @classmethod @@ -1782,7 +1782,7 @@ def __init__(self, coefficient_ring, indices, category, minimize_results): """ self._indices_ = indices self._minimize_results_ = minimize_results - super(RecognizableSeriesSpace, self).__init__( + super().__init__( category=category, base=coefficient_ring) def __reduce__(self): diff --git a/src/sage/combinat/regular_sequence.py b/src/sage/combinat/regular_sequence.py index a10ceb7cf17..c585e51e194 100644 --- a/src/sage/combinat/regular_sequence.py +++ b/src/sage/combinat/regular_sequence.py @@ -1510,7 +1510,7 @@ def some_elements(self): """ return iter(element.regenerated() for element - in super(RegularSequenceRing, self).some_elements( + in super().some_elements( allow_degenerated_sequence=True)) def _element_constructor_(self, *args, **kwds): @@ -1537,7 +1537,7 @@ def _element_constructor_(self, *args, **kwds): 2-regular sequence 1, 3, 6, 9, 12, 18, 18, 27, 24, 36, ... """ allow_degenerated_sequence = kwds.pop('allow_degenerated_sequence', False) - element = super(RegularSequenceRing, self)._element_constructor_(*args, **kwds) + element = super()._element_constructor_(*args, **kwds) if not allow_degenerated_sequence: element._error_if_degenerated_() return element diff --git a/src/sage/combinat/ribbon_shaped_tableau.py b/src/sage/combinat/ribbon_shaped_tableau.py index a5bfc841e7b..4115a6a13aa 100644 --- a/src/sage/combinat/ribbon_shaped_tableau.py +++ b/src/sage/combinat/ribbon_shaped_tableau.py @@ -191,7 +191,7 @@ class based on input. # return RibbonShapedTableaux_shape(Partition(shape)) # Otherwise arg0 takes the place of the category in pickling - return super(RibbonShapedTableaux, cls).__classcall__(cls, **kwds) + return super().__classcall__(cls, **kwds) def __init__(self, category=None): """ @@ -262,7 +262,7 @@ class based on input. return StandardRibbonShapedTableaux_shape(Partition(shape)) # Otherwise arg0 takes the place of the category in pickling - return super(StandardRibbonShapedTableaux, cls).__classcall__(cls, **kwds) + return super().__classcall__(cls, **kwds) def __init__(self, category=None): """ diff --git a/src/sage/combinat/rigged_configurations/kleber_tree.py b/src/sage/combinat/rigged_configurations/kleber_tree.py index 2403ad7ab05..b4a57e365f6 100644 --- a/src/sage/combinat/rigged_configurations/kleber_tree.py +++ b/src/sage/combinat/rigged_configurations/kleber_tree.py @@ -609,7 +609,7 @@ def __classcall_private__(cls, cartan_type, B, classical=None): classical = cartan_type.classical() else: classical = CartanType(classical) - return super(KleberTree, cls).__classcall__(cls, cartan_type, B, classical) + return super().__classcall__(cls, cartan_type, B, classical) def __init__(self, cartan_type, B, classical_ct): r""" @@ -811,8 +811,7 @@ def _children_iter(self, node): # tradeoff occurs between the methods. However, this may grow as # the _children_iter_vector is further optimized. if node != self.root and prod(val+1 for val in node.up_root.coefficients()) < 1000: - for x in self._children_iter_vector(node): - yield x + yield from self._children_iter_vector(node) return n = self._classical_ct.rank() @@ -985,8 +984,7 @@ def _depth_first_iter(self, cur): yield cur for child in cur.children: - for x in self._depth_first_iter(child): - yield x + yield from self._depth_first_iter(child) __iter__ = breadth_first_iter @@ -1160,7 +1158,7 @@ def __classcall_private__(cls, cartan_type, B): return KleberTreeTypeA2Even(cartan_type, B) if cartan_type.classical().is_simply_laced(): raise ValueError("use KleberTree for simply-laced types") - return super(VirtualKleberTree, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): """ @@ -1354,7 +1352,7 @@ def __classcall_private__(cls, cartan_type, B): cartan_type = CartanType(cartan_type) # Standardize B input into a tuple of tuples B = tuple(map(tuple, B)) - return super(KleberTreeTypeA2Even, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): """ diff --git a/src/sage/combinat/rigged_configurations/kr_tableaux.py b/src/sage/combinat/rigged_configurations/kr_tableaux.py index 3addee9e2e5..8bdc1d275b9 100644 --- a/src/sage/combinat/rigged_configurations/kr_tableaux.py +++ b/src/sage/combinat/rigged_configurations/kr_tableaux.py @@ -554,7 +554,7 @@ def tensor(self, *crystals, **options): elif isinstance(B, KirillovReshetikhinTableaux): dims.append([B._r, B._s]) return TensorProductOfKirillovReshetikhinTableaux(ct, dims) - return super(KirillovReshetikhinTableaux, self).tensor(*crystals, **options) + return super().tensor(*crystals, **options) @lazy_attribute def _tableau_height(self): diff --git a/src/sage/combinat/rigged_configurations/rc_crystal.py b/src/sage/combinat/rigged_configurations/rc_crystal.py index 647d3c6eb0d..13bc6a86cfa 100644 --- a/src/sage/combinat/rigged_configurations/rc_crystal.py +++ b/src/sage/combinat/rigged_configurations/rc_crystal.py @@ -153,7 +153,7 @@ def __classcall_private__(cls, cartan_type, wt=None, WLR=None): if isinstance(cartan_type, CartanTypeFolded): return CrystalOfNonSimplyLacedRC(cartan_type, wt, WLR) - return super(CrystalOfRiggedConfigurations, cls).__classcall__(cls, wt, WLR=WLR) + return super().__classcall__(cls, wt, WLR=WLR) def __init__(self, wt, WLR): r""" diff --git a/src/sage/combinat/rigged_configurations/rc_infinity.py b/src/sage/combinat/rigged_configurations/rc_infinity.py index e592f9b3656..d633f50abca 100644 --- a/src/sage/combinat/rigged_configurations/rc_infinity.py +++ b/src/sage/combinat/rigged_configurations/rc_infinity.py @@ -147,7 +147,7 @@ def __classcall_private__(cls, cartan_type): return InfinityCrystalOfNonSimplyLacedRC(cartan_type) cartan_type = CartanType(cartan_type) - return super(InfinityCrystalOfRiggedConfigurations, cls).__classcall__(cls, cartan_type) + return super().__classcall__(cls, cartan_type) def __init__(self, cartan_type): r""" @@ -241,7 +241,7 @@ def _coerce_map_from_(self, P): and self.cartan_type().is_simply_laced()): from sage.combinat.rigged_configurations.bij_infinity import FromTableauIsomorphism return FromTableauIsomorphism(Hom(P, self)) - return super(InfinityCrystalOfRiggedConfigurations, self)._coerce_map_from_(P) + return super()._coerce_map_from_(P) def _calc_vacancy_number(self, partitions, a, i, **options): r""" @@ -358,7 +358,7 @@ def _coerce_map_from_(self, P): if isinstance(P, InfinityCrystalOfTableaux): from sage.combinat.rigged_configurations.bij_infinity import FromTableauIsomorphism return FromTableauIsomorphism(Hom(P, self)) - return super(InfinityCrystalOfNonSimplyLacedRC, self)._coerce_map_from_(P) + return super()._coerce_map_from_(P) def _calc_vacancy_number(self, partitions, a, i): r""" diff --git a/src/sage/combinat/rigged_configurations/rigged_configurations.py b/src/sage/combinat/rigged_configurations/rigged_configurations.py index b822a668612..2d558322721 100644 --- a/src/sage/combinat/rigged_configurations/rigged_configurations.py +++ b/src/sage/combinat/rigged_configurations/rigged_configurations.py @@ -358,7 +358,7 @@ def __classcall_private__(cls, cartan_type, B): if not cartan_type.classical().is_simply_laced(): return RCNonSimplyLaced(cartan_type, B) - return super(RiggedConfigurations, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): r""" @@ -476,7 +476,7 @@ def _repr_option(self, key): """ if key == 'element_ascii_art': return self.options.element_ascii_art - return super(RiggedConfigurations, self)._repr_option(key) + return super()._repr_option(key) def __iter__(self): """ @@ -1062,7 +1062,7 @@ def tensor(self, *crystals, **options): for B in crystals: dims += B.dims return RiggedConfigurations(ct, dims) - return super(RiggedConfigurations, self).tensor(*crystals, **options) + return super().tensor(*crystals, **options) Element = KRRCSimplyLacedElement @@ -1093,7 +1093,7 @@ def __classcall_private__(cls, cartan_type, B): # Standardize B input into a tuple of tuples B = tuple(map(tuple, B)) - return super(RCNonSimplyLaced, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, dims): """ diff --git a/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py b/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py index 3314986004f..a2ccd72e902 100644 --- a/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py +++ b/src/sage/combinat/rigged_configurations/tensor_product_kr_tableaux.py @@ -133,8 +133,7 @@ def __iter__(self): if self._cache is None: self._cache = tuple([x.to_tensor_product_of_kirillov_reshetikhin_tableaux() for x in self.tp_krt.rigged_configurations().module_generators]) - for x in self._cache: - yield x + yield from self._cache def __repr__(self): """ @@ -296,7 +295,7 @@ def __classcall_private__(cls, cartan_type, B): # Standardize B input into a tuple of tuples B = tuple(tuple(dim) for dim in B) - return super(TensorProductOfKirillovReshetikhinTableaux, cls).__classcall__(cls, cartan_type, B) + return super().__classcall__(cls, cartan_type, B) def __init__(self, cartan_type, B): r""" @@ -493,7 +492,7 @@ def tensor(self, *crystals, **options): elif isinstance(B, KirillovReshetikhinTableaux): dims.append([B._r, B._s]) return TensorProductOfKirillovReshetikhinTableaux(ct, dims) - return super(TensorProductOfKirillovReshetikhinTableaux, self).tensor(*crystals, **options) + return super().tensor(*crystals, **options) TensorProductOfKirillovReshetikhinTableaux.Element = TensorProductOfKirillovReshetikhinTableauxElement diff --git a/src/sage/combinat/root_system/type_relabel.py b/src/sage/combinat/root_system/type_relabel.py index 142ddeffa45..965ab598cfb 100644 --- a/src/sage/combinat/root_system/type_relabel.py +++ b/src/sage/combinat/root_system/type_relabel.py @@ -55,7 +55,7 @@ def __classcall__(cls, type, relabelling): return type relabelling = FiniteFamily(relabelling) # Hack to emulate a frozendict which would be hashable!!!! - return super(CartanType, cls).__classcall__(cls, type, relabelling) + return super().__classcall__(cls, type, relabelling) def __init__(self, type, relabelling): """ diff --git a/src/sage/combinat/species/cycle_species.py b/src/sage/combinat/species/cycle_species.py index 335223143ed..ed442e75ba9 100644 --- a/src/sage/combinat/species/cycle_species.py +++ b/src/sage/combinat/species/cycle_species.py @@ -113,7 +113,7 @@ def __classcall__(cls, *args, **kwds): sage: C = species.CycleSpecies(); C Cyclic permutation species """ - return super(CycleSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/linear_order_species.py b/src/sage/combinat/species/linear_order_species.py index a62fde28fb5..6203442ec8f 100644 --- a/src/sage/combinat/species/linear_order_species.py +++ b/src/sage/combinat/species/linear_order_species.py @@ -77,7 +77,7 @@ def __classcall__(cls, *args, **kwds): sage: L = species.LinearOrderSpecies(); L Linear order species """ - return super(LinearOrderSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/partition_species.py b/src/sage/combinat/species/partition_species.py index 3ed00b45ca4..f9044db7c73 100644 --- a/src/sage/combinat/species/partition_species.py +++ b/src/sage/combinat/species/partition_species.py @@ -142,7 +142,7 @@ def __classcall__(cls, *args, **kwds): sage: P = species.PartitionSpecies(); P Partition species """ - return super(PartitionSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/permutation_species.py b/src/sage/combinat/species/permutation_species.py index 4549e0354ff..64534c9e8bb 100644 --- a/src/sage/combinat/species/permutation_species.py +++ b/src/sage/combinat/species/permutation_species.py @@ -115,7 +115,7 @@ def __classcall__(cls, *args, **kwds): sage: P = species.PermutationSpecies(); P Permutation species """ - return super(PermutationSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/set_species.py b/src/sage/combinat/species/set_species.py index c4942dc653d..daa7d7e5835 100644 --- a/src/sage/combinat/species/set_species.py +++ b/src/sage/combinat/species/set_species.py @@ -91,7 +91,7 @@ def __classcall__(cls, *args, **kwds): sage: E = species.SetSpecies(); E Set species """ - return super(SetSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/species/subset_species.py b/src/sage/combinat/species/subset_species.py index 2bd89885533..81156e5183d 100644 --- a/src/sage/combinat/species/subset_species.py +++ b/src/sage/combinat/species/subset_species.py @@ -134,7 +134,7 @@ def __classcall__(cls, *args, **kwds): sage: S = species.SubsetSpecies(); S Subset species """ - return super(SubsetSpecies, cls).__classcall__(cls, *args, **kwds) + return super().__classcall__(cls, *args, **kwds) def __init__(self, min=None, max=None, weight=None): """ diff --git a/src/sage/combinat/tableau.py b/src/sage/combinat/tableau.py index 2103cb810a7..f7e58a15c20 100644 --- a/src/sage/combinat/tableau.py +++ b/src/sage/combinat/tableau.py @@ -9440,8 +9440,7 @@ def __iter__(self): for (r, c) in growth_choice: new_tab[r][c] = growth_num list_of_partial_inc_tabs.append(Tableau(new_tab)) - for inctab in list_of_inc_tabs: - yield inctab + yield from list_of_inc_tabs class IncreasingTableaux_size_weight(IncreasingTableaux): diff --git a/src/sage/combinat/words/abstract_word.py b/src/sage/combinat/words/abstract_word.py index 77174089f78..610dba1437a 100644 --- a/src/sage/combinat/words/abstract_word.py +++ b/src/sage/combinat/words/abstract_word.py @@ -900,8 +900,7 @@ def _iterated_right_palindromic_closure_iterator(self, f=None): w = (w*par([letter])).palindromic_closure(f=f) length_after = w.length() d = length_after - length_before - for a in w[-d:]: - yield a + yield from w[-d:] def _iterated_right_palindromic_closure_recursive_iterator(self, f=None): r""" @@ -991,8 +990,7 @@ def _iterated_right_palindromic_closure_recursive_iterator(self, f=None): else: to_append = ipcw[lengths[pos]:] ipcw += to_append - for a in to_append: - yield a + yield from to_append def iterated_right_palindromic_closure(self, f=None, algorithm='recursive'): r""" diff --git a/src/sage/combinat/words/word_generators.py b/src/sage/combinat/words/word_generators.py index 06141373c85..d7093ae997c 100644 --- a/src/sage/combinat/words/word_generators.py +++ b/src/sage/combinat/words/word_generators.py @@ -1651,8 +1651,7 @@ def _s_adic_iterator(self, sequence, letters): if not precedent_letter == m(a)[0]: raise ValueError("the hypothesis of the algorithm used is not satisfied; the image of the %s-th letter (=%s) under the %s-th morphism (=%s) should start with the %s-th letter (=%s)" % (i+1,a,i+1,m,i,precedent_letter)) w = p(m(a)[1:]) - for b in w: - yield b + yield from w p = p * m precedent_letter = a diff --git a/src/sage/combinat/words/words.py b/src/sage/combinat/words/words.py index 900ab9c8508..63d6f1f0d05 100644 --- a/src/sage/combinat/words/words.py +++ b/src/sage/combinat/words/words.py @@ -960,8 +960,7 @@ def __iter__(self): word: 444 """ for l in itertools.count(): - for w in self.iterate_by_length(l): - yield w + yield from self.iterate_by_length(l) def __contains__(self, x): """ diff --git a/src/sage/cpython/_py2_random.py b/src/sage/cpython/_py2_random.py index 1cd9532fee4..3ba96ccbbd1 100644 --- a/src/sage/cpython/_py2_random.py +++ b/src/sage/cpython/_py2_random.py @@ -92,19 +92,19 @@ def seed(self, a=None): import time a = int(time.time() * 256) # use fractional seconds - super(Random, self).seed(a) + super().seed(a) self.gauss_next = None def getstate(self): """Return internal state; can be passed to setstate() later.""" - return self.VERSION, super(Random, self).getstate(), self.gauss_next + return self.VERSION, super().getstate(), self.gauss_next def setstate(self, state): """Restore internal state from object returned by getstate().""" version = state[0] if version == 3: version, internalstate, self.gauss_next = state - super(Random, self).setstate(internalstate) + super().setstate(internalstate) elif version == 2: version, internalstate, self.gauss_next = state # In version 2, the state was saved as signed ints, which causes @@ -115,7 +115,7 @@ def setstate(self, state): internalstate = tuple( int(x) % (2**32) for x in internalstate ) except ValueError as e: raise TypeError(e) - super(Random, self).setstate(internalstate) + super().setstate(internalstate) else: raise ValueError("state with version %s passed to " "Random.setstate() of version %s" % @@ -131,7 +131,7 @@ def jumpahead(self, n): # we use hashing to create a large n for the shuffle. s = repr(n) + repr(self.getstate()) n = int(_hashlib.new('sha512', s).hexdigest(), 16) - super(Random, self).jumpahead(n) + super().jumpahead(n) ## ---- Methods below this point do not need to be overridden when ## ---- subclassing for the purpose of using a different core generator. diff --git a/src/sage/data_structures/mutable_poset.py b/src/sage/data_structures/mutable_poset.py index 44d086fa920..97bfcf1cd52 100644 --- a/src/sage/data_structures/mutable_poset.py +++ b/src/sage/data_structures/mutable_poset.py @@ -947,9 +947,8 @@ def _iter_depth_first_visit_(self, marked, if key is not None: S = sorted(S, key=key) for shell in S: - for e in shell._iter_depth_first_visit_(marked, reverse, - key, condition): - yield e + yield from shell._iter_depth_first_visit_(marked, reverse, + key, condition) def iter_depth_first(self, reverse=False, key=None, condition=None): r""" @@ -1072,9 +1071,8 @@ def _iter_topological_visit_(self, marked, if key is not None and len(S) > 1: S = sorted(S, key=key) for shell in S: - for e in shell._iter_topological_visit_(marked, reverse, - key, condition): - yield e + yield from shell._iter_topological_visit_(marked, reverse, + key, condition) yield self def iter_topological(self, reverse=False, key=None, condition=None): @@ -1768,8 +1766,7 @@ def shells(self, include_special=False): """ if include_special: yield self.null - for e in self._shells_.values(): - yield e + yield from self._shells_.values() if include_special: yield self.oo diff --git a/src/sage/databases/stein_watkins.py b/src/sage/databases/stein_watkins.py index 167fa3a195b..6abf39426dd 100644 --- a/src/sage/databases/stein_watkins.py +++ b/src/sage/databases/stein_watkins.py @@ -158,8 +158,7 @@ def __len__(self): def __iter__(self): try: - for E in self.curves: - yield E + yield from self.curves except AttributeError: return diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py index b5521868dd5..6c3b0b225ac 100644 --- a/src/sage/doctest/forker.py +++ b/src/sage/doctest/forker.py @@ -503,7 +503,7 @@ def getvalue(self): TestResults = namedtuple('TestResults', 'failed attempted') -class SageDocTestRunner(doctest.DocTestRunner, object): +class SageDocTestRunner(doctest.DocTestRunner): def __init__(self, *args, **kwds): """ A customized version of DocTestRunner that tracks dependencies diff --git a/src/sage/features/join_feature.py b/src/sage/features/join_feature.py index 802cb433ba3..6360eec1576 100644 --- a/src/sage/features/join_feature.py +++ b/src/sage/features/join_feature.py @@ -148,7 +148,7 @@ def hide(self): """ for f in self._features: f.hide() - super(JoinFeature, self).hide() + super().hide() def unhide(self): r""" @@ -172,4 +172,4 @@ def unhide(self): """ for f in self._features: f.unhide() - super(JoinFeature, self).unhide() + super().unhide() diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py index 7a9322973ad..f4e0dc1bdbf 100644 --- a/src/sage/functions/orthogonal_polys.py +++ b/src/sage/functions/orthogonal_polys.py @@ -454,7 +454,7 @@ def __init__(self, name, nargs=2, latex_name=None, conversions=None): self._maxima_name = conversions['maxima'] except KeyError: pass - super(OrthogonalFunction, self).__init__(name=name, nargs=nargs, + super().__init__(name=name, nargs=nargs, latex_name=latex_name, conversions=conversions) @@ -529,7 +529,7 @@ def __call__(self, *args, **kwds): kwds['hold'] = True return _maxima(self._eval_(*args, **kwds))._sage_() - return super(OrthogonalFunction, self).__call__(*args, **kwds) + return super().__call__(*args, **kwds) class ChebyshevFunction(OrthogonalFunction): @@ -575,7 +575,7 @@ def __call__(self, n, *args, **kwds): except Exception: pass - return super(ChebyshevFunction, self).__call__(n, *args, **kwds) + return super().__call__(n, *args, **kwds) def _eval_(self, n, x): """ diff --git a/src/sage/functions/piecewise.py b/src/sage/functions/piecewise.py index ff3851a1776..4e8588ad05c 100644 --- a/src/sage/functions/piecewise.py +++ b/src/sage/functions/piecewise.py @@ -473,8 +473,7 @@ def items(self, parameters, variable): support is {0}, function is sin(x) support is (0, 2), function is cos(x) """ - for pair in parameters: - yield pair + yield from parameters def __call__(self, parameters, variable, value=None, **kwds): """ diff --git a/src/sage/geometry/polyhedral_complex.py b/src/sage/geometry/polyhedral_complex.py index 2e20e508057..d6e3b075656 100644 --- a/src/sage/geometry/polyhedral_complex.py +++ b/src/sage/geometry/polyhedral_complex.py @@ -415,8 +415,7 @@ def cell_iterator(self, increasing=True): dim_index = reversed(dim_index) for d in dim_index: if d in cells: - for c in cells[d]: - yield c + yield from cells[d] def _n_cells_sorted(self, n, subcomplex=None): """ @@ -543,8 +542,7 @@ def maximal_cell_iterator(self, increasing=False): dim_index = reversed(dim_index) for d in dim_index: if d in maximal_cells: - for c in maximal_cells[d]: - yield c + yield from maximal_cells[d] def n_maximal_cells(self, n): r""" diff --git a/src/sage/geometry/polyhedron/base0.py b/src/sage/geometry/polyhedron/base0.py index 556eefc5148..4b31a8eb6ed 100644 --- a/src/sage/geometry/polyhedron/base0.py +++ b/src/sage/geometry/polyhedron/base0.py @@ -753,8 +753,7 @@ def Hrep_generator(self): sage: next(p.Hrep_generator()) An inequality (-1, 0, 0) x + 1 >= 0 """ - for H in self.Hrepresentation(): - yield H + yield from self.Hrepresentation() @cached_method def n_Hrepresentation(self): @@ -843,8 +842,7 @@ def Vrep_generator(self): sage: next(vg) A vertex at (1, 1, 1) """ - for V in self.Vrepresentation(): - yield V + yield from self.Vrepresentation() def inequality_generator(self): """ diff --git a/src/sage/geometry/polyhedron/generating_function.py b/src/sage/geometry/polyhedron/generating_function.py index 2c6cfccf200..7a33bd528b9 100644 --- a/src/sage/geometry/polyhedron/generating_function.py +++ b/src/sage/geometry/polyhedron/generating_function.py @@ -772,7 +772,7 @@ def decode_factor(factor): return _simplify_(numerator, terms) -class _TransformHrepresentation(object): +class _TransformHrepresentation: r""" An abstract base class for transformations of the Hrepresentation of a polyhedron together with its @@ -1428,7 +1428,7 @@ def __init__(self, inequalities, equations, B, mod): <..._TransformMod object at 0x...> """ self.mod = mod - super(_TransformMod, self).__init__(inequalities, equations, B) + super().__init__(inequalities, equations, B) def _transform_(self): r""" diff --git a/src/sage/geometry/polyhedron/plot.py b/src/sage/geometry/polyhedron/plot.py index b6bb235b711..03628f60e22 100644 --- a/src/sage/geometry/polyhedron/plot.py +++ b/src/sage/geometry/polyhedron/plot.py @@ -843,8 +843,7 @@ def defining_equation(): # corresponding to a polygon if polyhedron.dim() < 3: yield next(polyhedron.equation_generator()) else: - for ineq in polyhedron.inequality_generator(): - yield ineq + yield from polyhedron.inequality_generator() faces = [] face_inequalities = [] diff --git a/src/sage/geometry/triangulation/element.py b/src/sage/geometry/triangulation/element.py index 16b55ab7cac..e8c8d7e1a51 100644 --- a/src/sage/geometry/triangulation/element.py +++ b/src/sage/geometry/triangulation/element.py @@ -336,8 +336,7 @@ def __iter__(self): ... StopIteration """ - for p in self._triangulation: - yield p + yield from self._triangulation def __getitem__(self, i): """ diff --git a/src/sage/geometry/triangulation/point_configuration.py b/src/sage/geometry/triangulation/point_configuration.py index 14afe670c16..68ac3119945 100644 --- a/src/sage/geometry/triangulation/point_configuration.py +++ b/src/sage/geometry/triangulation/point_configuration.py @@ -501,8 +501,7 @@ def __iter__(self): sage: [p.point(i) for i in range(p.n_points())] [P(1, 1), P(2, 2), P(3, 3)] """ - for p in self.points(): - yield p + yield from self.points() def _repr_(self): r""" @@ -719,8 +718,7 @@ def _TOPCOM_triangulations(self, verbose=True): if self._regular is False: command += ' --nonregular' - for t in self._TOPCOM_communicate(command, verbose): - yield t + yield from self._TOPCOM_communicate(command, verbose) def _TOPCOM_triangulate(self, verbose=True): r""" @@ -988,8 +986,7 @@ def triangulations(self, verbose=False): sage: p.set_engine('internal') """ if self._use_TOPCOM: - for triangulation in self._TOPCOM_triangulations(verbose): - yield triangulation + yield from self._TOPCOM_triangulations(verbose) else: if not self._connected: raise ValueError('Need TOPCOM to find disconnected triangulations.') diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py index eedbc36bef3..1782d08dbda 100644 --- a/src/sage/graphs/generic_graph.py +++ b/src/sage/graphs/generic_graph.py @@ -11431,8 +11431,7 @@ def neighbor_iterator(self, vertex, closed=False): if not self.has_edge(vertex, vertex): yield vertex - for u in self._backend.iterator_nbrs(vertex): - yield u + yield from self._backend.iterator_nbrs(vertex) def vertices(self, sort=False, key=None, degree=None, vertex_property=None): r""" diff --git a/src/sage/graphs/graph.py b/src/sage/graphs/graph.py index 718dbdad745..60ab129f1c2 100644 --- a/src/sage/graphs/graph.py +++ b/src/sage/graphs/graph.py @@ -9039,8 +9039,7 @@ def rec(G): # For each unlabeled matching, we yield all its possible labelings for m in rec(G): - for pm in itertools.product(*[edges[frozenset(e)] for e in m]): - yield pm + yield from itertools.product(*[edges[frozenset(e)] for e in m]) @doc_index("Leftovers") def has_perfect_matching(self, algorithm="Edmonds", solver=None, verbose=0, diff --git a/src/sage/graphs/graph_generators.py b/src/sage/graphs/graph_generators.py index e45371bc6d9..ce213b738c3 100644 --- a/src/sage/graphs/graph_generators.py +++ b/src/sage/graphs/graph_generators.py @@ -1521,8 +1521,7 @@ def fullerenes(self, order, ipr=False): sp.stdout.reconfigure(newline='') - for G in graphs._read_planar_code(sp.stdout): - yield(G) + yield from graphs._read_planar_code(sp.stdout) def fusenes(self, hexagon_count, benzenoids=False): r""" @@ -1797,8 +1796,7 @@ def plantri_gen(self, options=""): sp.stdout.reconfigure(newline='') try: - for G in graphs._read_planar_code(sp.stdout): - yield(G) + yield from graphs._read_planar_code(sp.stdout) except AssertionError: raise AttributeError("invalid options '{}'".format(options)) diff --git a/src/sage/homology/chain_complex.py b/src/sage/homology/chain_complex.py index 7a56cf3fc4b..16f2a78c7db 100644 --- a/src/sage/homology/chain_complex.py +++ b/src/sage/homology/chain_complex.py @@ -353,7 +353,7 @@ def __init__(self, parent, vectors, check=True): and v.base_ring() is parent.base_ring() for v in vectors.values()) self._vec = vectors - super(Chain_class, self).__init__(parent) + super().__init__(parent) def vector(self, degree): """ @@ -688,7 +688,7 @@ def __init__(self, grading_group, degree_of_differential, base_ring, differentia from sage.categories.chain_complexes import ChainComplexes category = ChainComplexes(base_ring) - super(ChainComplex_class, self).__init__(base=base_ring, category=category) + super().__init__(base=base_ring, category=category) Element = Chain_class diff --git a/src/sage/homology/koszul_complex.py b/src/sage/homology/koszul_complex.py index a8b050e09bc..22a1ceb5d80 100644 --- a/src/sage/homology/koszul_complex.py +++ b/src/sage/homology/koszul_complex.py @@ -115,7 +115,7 @@ def __classcall_private__(cls, R=None, elements=None): R = elements[0].parent() elif R is None: # elements is not None R = elements[0].parent() - return super(KoszulComplex, cls).__classcall__(cls, R, tuple(elements)) + return super().__classcall__(cls, R, tuple(elements)) def __init__(self, R, elements): """ diff --git a/src/sage/interfaces/polymake.py b/src/sage/interfaces/polymake.py index c857d14daf9..9161ebd5377 100644 --- a/src/sage/interfaces/polymake.py +++ b/src/sage/interfaces/polymake.py @@ -341,7 +341,7 @@ def to_str(x): except NotImplementedError: pass - return super(PolymakeAbstract, self)._coerce_impl(x, use_special=use_special) + return super()._coerce_impl(x, use_special=use_special) def console(self): """ @@ -1587,7 +1587,7 @@ def str_to_base_ring(s): from sage.geometry.polyhedron.backend_polymake import Polyhedron_polymake return Polyhedron_polymake._from_polymake_polytope(None, self) else: - return super(PolymakeElement, self)._sage_() + return super()._sage_() def _sage_doc_(self): """ diff --git a/src/sage/interfaces/r.py b/src/sage/interfaces/r.py index 068e65a2096..bdf50dbfed9 100644 --- a/src/sage/interfaces/r.py +++ b/src/sage/interfaces/r.py @@ -560,7 +560,7 @@ def _coerce_impl(self, x, use_special=True): # cannot be used as input if isinstance(x, bool): return self('TRUE' if x else 'FALSE') - return super(R, self)._coerce_impl(x, use_special=use_special) + return super()._coerce_impl(x, use_special=use_special) def set_seed(self, seed=None): """ diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py index f4e5c6a9158..331d698d3ab 100644 --- a/src/sage/interfaces/singular.py +++ b/src/sage/interfaces/singular.py @@ -1398,7 +1398,7 @@ def _repr_(self): """ - s = super(SingularElement, self)._repr_() + s = super()._repr_() if self._name in s: if self.get_custom_name() is None and self.type() == 'matrix': s = self.parent().eval('pmat(%s,20)' % (self.name())) diff --git a/src/sage/matrix/compute_J_ideal.py b/src/sage/matrix/compute_J_ideal.py index 3055f283a78..1983e16c0f5 100644 --- a/src/sage/matrix/compute_J_ideal.py +++ b/src/sage/matrix/compute_J_ideal.py @@ -334,7 +334,7 @@ def __init__(self, B): """ from sage.rings.polynomial.polynomial_ring import polygen - super(ComputeMinimalPolynomials, self).__init__() + super().__init__() if not B.is_square(): raise TypeError("square matrix required") diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py index c307f4c28e4..279eba44511 100644 --- a/src/sage/matrix/matrix_space.py +++ b/src/sage/matrix/matrix_space.py @@ -2355,8 +2355,7 @@ def some_elements(self): ) """ yield self.an_element() - for g in self.gens(): - yield g + yield from self.gens() def _magma_init_(self, magma): r""" diff --git a/src/sage/misc/bindable_class.py b/src/sage/misc/bindable_class.py index 86d04bc8770..9213db6008e 100644 --- a/src/sage/misc/bindable_class.py +++ b/src/sage/misc/bindable_class.py @@ -213,7 +213,7 @@ class BoundClass(functools.partial): __doc__ = None # See warning above def __init__(self, *args): - super(BoundClass, self).__init__() + super().__init__() self.__doc__ = self.func.__doc__ def __repr__(self): diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py index 8f584a211ef..5a65b4260f0 100644 --- a/src/sage/modules/free_module.py +++ b/src/sage/modules/free_module.py @@ -5387,7 +5387,7 @@ def _coerce_map_from_(self, M): if (self.base_ring().has_coerce_map_from(M.base_ring()) and self.rank() == M.degree()): return True - return super(FreeModule_ambient, self)._coerce_map_from_(M) + return super()._coerce_map_from_(M) def _dense_module(self): """ diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py index 2bae4dd2df0..93f22993eb3 100644 --- a/src/sage/rings/number_field/class_group.py +++ b/src/sage/rings/number_field/class_group.py @@ -591,8 +591,7 @@ def _iter_inner(self, i0, k): return gk = self.gen(k) for _ in range(self._gens_orders[k]): - for J in self._iter_inner(i0, k + 1): - yield J + yield from self._iter_inner(i0, k + 1) i0 = i0 * gk return diff --git a/src/sage/rings/padics/padic_extension_generic.py b/src/sage/rings/padics/padic_extension_generic.py index dc80e998bcd..59264f4f0f4 100644 --- a/src/sage/rings/padics/padic_extension_generic.py +++ b/src/sage/rings/padics/padic_extension_generic.py @@ -632,7 +632,7 @@ def free_module(self, base=None, basis=None, map=True): from_V = MapFreeModuleToTwoStep to_V = MapTwoStepToFreeModule elif base is self: - return super(pAdicExtensionGeneric, self).free_module(base=base, basis=basis, map=map) + return super().free_module(base=base, basis=basis, map=map) else: raise NotImplementedError FromV = Hom(V, self) diff --git a/src/sage/rings/padics/padic_extension_leaves.py b/src/sage/rings/padics/padic_extension_leaves.py index bf5599f7c59..44156a85075 100644 --- a/src/sage/rings/padics/padic_extension_leaves.py +++ b/src/sage/rings/padics/padic_extension_leaves.py @@ -483,7 +483,7 @@ def _coerce_map_from_(self, R): from sage.rings.padics.qadic_flint_FP import pAdicCoercion_FP_frac_field return pAdicCoercion_FP_frac_field(R, self) - return super(UnramifiedExtensionFieldFloatingPoint, self)._coerce_map_from_(R) + return super()._coerce_map_from_(R) class EisensteinExtensionRingCappedRelative(EisensteinExtensionGeneric, pAdicCappedRelativeRingGeneric): """ diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py index 90e9d205ac5..ec85d00c3f2 100644 --- a/src/sage/rings/padics/padic_valuation.py +++ b/src/sage/rings/padics/padic_valuation.py @@ -1428,7 +1428,7 @@ def extensions(self, ring): G = ring.relative_polynomial() approximant = self._base_valuation.change_domain(G.parent())._initial_approximation return [pAdicValuation(ring, approximant)] - return super(pAdicFromLimitValuation, self).extensions(ring) + return super().extensions(ring) def _fraction_field(ring): r""" diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py index c0f3fb20fdf..1bc872ad93b 100644 --- a/src/sage/schemes/projective/projective_morphism.py +++ b/src/sage/schemes/projective/projective_morphism.py @@ -2325,7 +2325,7 @@ def __call__(self, x): reprs = self.representatives() except NotImplementedError: # Singular does not support the base field try: - return super(SchemeMorphism_polynomial_projective_subscheme_field, self).__call__(x) + return super().__call__(x) except ValueError: raise ValueError('cannot apply the morphism to this point') diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py index 8970637882d..0ccfbcd65b9 100644 --- a/src/sage/schemes/projective/projective_subscheme.py +++ b/src/sage/schemes/projective/projective_subscheme.py @@ -1513,4 +1513,4 @@ def local_height_arch(self, i, prec=None): sage: X.local_height_arch(1) 4.61512051684126 """ - return self.Chow_form().local_height_arch(i, prec) \ No newline at end of file + return self.Chow_form().local_height_arch(i, prec) diff --git a/src/sage/sets/family.py b/src/sage/sets/family.py index 6c007a96835..f3c3d0a7556 100644 --- a/src/sage/sets/family.py +++ b/src/sage/sets/family.py @@ -1508,8 +1508,7 @@ def __iter__(self): sage: [i for i in f] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]] """ - for i in self.enumset: - yield i + yield from self.enumset def __getitem__(self, i): """ diff --git a/src/sage/sets/set.py b/src/sage/sets/set.py index a6a746e9aca..2ac71e73dbf 100644 --- a/src/sage/sets/set.py +++ b/src/sage/sets/set.py @@ -1467,10 +1467,8 @@ def __iter__(self): sage: [x for x in Set(GF(3)).union(Set(GF(2)))] [0, 1, 2, 0, 1] """ - for x in self._X: - yield x - for y in self._Y: - yield y + yield from self._X + yield from self._Y def __contains__(self, x): """ diff --git a/src/sage/tensor/modules/finite_rank_free_module.py b/src/sage/tensor/modules/finite_rank_free_module.py index d868c50b109..d8d8686eeae 100644 --- a/src/sage/tensor/modules/finite_rank_free_module.py +++ b/src/sage/tensor/modules/finite_rank_free_module.py @@ -1210,7 +1210,7 @@ def __classcall_private__(cls, ring, rank, name=None, latex_name=None, start_ind category = Modules(ring).FiniteDimensional().or_subcategory(category) if latex_name is None: latex_name = name - return super(FiniteRankFreeModule, cls).__classcall__( + return super().__classcall__( cls, ring, rank, name, latex_name, start_index, output_formatter, category, ambient) def __init__( diff --git a/src/sage/tensor/modules/free_module_basis.py b/src/sage/tensor/modules/free_module_basis.py index 7fb776621b9..e44276a4317 100644 --- a/src/sage/tensor/modules/free_module_basis.py +++ b/src/sage/tensor/modules/free_module_basis.py @@ -700,7 +700,7 @@ def __classcall_private__(cls, fmodule, symbol, latex_symbol=None, symbol_dual = tuple(symbol_dual) if isinstance(latex_symbol_dual, list): latex_symbol_dual = tuple(latex_symbol_dual) - return super(FreeModuleBasis, cls).__classcall__(cls, fmodule, symbol, + return super().__classcall__(cls, fmodule, symbol, latex_symbol=latex_symbol, indices=indices, latex_indices=latex_indices, diff --git a/src/sage/topology/simplicial_complex.py b/src/sage/topology/simplicial_complex.py index e3b8f9a853c..8ca615e3488 100644 --- a/src/sage/topology/simplicial_complex.py +++ b/src/sage/topology/simplicial_complex.py @@ -1394,8 +1394,7 @@ def face_iterator(self, increasing=True): if not increasing: dim_index = reversed(dim_index) for i in dim_index: - for F in Fs[i]: - yield F + yield from Fs[i] cells = faces