Skip to content

let shorthands be tuple and immutable #40271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 deletions src/sage/algebras/iwahori_hecke_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,17 @@ def __init__(self, W, q1, q2, base_ring):
# Attach the generic Hecke algebra and the basis change maps
self._root = root
self._generic_iwahori_hecke_algebra = IwahoriHeckeAlgebra_nonstandard(W)
self._shorthands = ['C', 'Cp', 'T']
self._shorthands = ('C', 'Cp', 'T')
else:
# Can we actually remove the bases C and Cp in this case?
self._root = None
self._shorthands = ['T']
self._shorthands = ('T',)

# if 2 is a unit in the base ring then add th A and B bases
try:
base_ring(base_ring.one() / 2)
self._shorthands.extend(['A', 'B'])
sh = self._shorthands
self._shorthands = (*sh, 'A', 'B')
except (TypeError, ZeroDivisionError):
pass

Expand Down Expand Up @@ -2785,7 +2786,7 @@ def __init__(self, W):
self.u_inv = normalized_laurent_polynomial(base_ring, u**-1)
self.v_inv = normalized_laurent_polynomial(base_ring, v**-1)

self._shorthands = ['C', 'Cp', 'T']
self._shorthands = ('C', 'Cp', 'T',)

if W.is_finite():
self._category = FiniteDimensionalAlgebrasWithBasis(base_ring)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/with_realizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def __init__(self, R, S):
F_to_Out .register_as_coercion()
(~F_to_Out).register_as_coercion()

_shorthands = ["F", "In", "Out"]
_shorthands = ("F", "In", "Out")

def a_realization(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/chas/fsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def __init__(self, base_ring):
cat = HopfAlgebras(base_ring).Graded().Connected()
Parent.__init__(self, base=base_ring, category=cat.WithRealizations())

_shorthands = ['G']
_shorthands = ('G',)

def a_realization(self):
r"""
Expand Down Expand Up @@ -790,7 +790,7 @@ class FreeSymmetricFunctions_Dual(UniqueRepresentation, Parent):
sage: TF(F[[5, 1, 4, 2, 3]])
F[135|2|4]
"""
def __init__(self, base_ring):
def __init__(self, base_ring) -> None:
r"""
Initialize ``self``.

Expand All @@ -802,7 +802,7 @@ def __init__(self, base_ring):
cat = HopfAlgebras(base_ring).Graded().Connected()
Parent.__init__(self, base=base_ring, category=cat.WithRealizations())

_shorthands = ['F']
_shorthands = ('F',)

def a_realization(self):
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/chas/wqsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def a_realization(self):
"""
return self.M()

_shorthands = tuple(['M', 'X', 'C', 'Q', 'Phi'])
_shorthands = ('M', 'X', 'C', 'Q', 'Phi')

# add options to class
class options(GlobalOptions):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/fqsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def a_realization(self):
"""
return self.F()

_shorthands = tuple(['F', 'G', 'M'])
_shorthands = ('F', 'G', 'M')

class F(FQSymBasis_abstract):
r"""
Expand Down
7 changes: 4 additions & 3 deletions src/sage/combinat/ncsf_qsym/ncsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ class NonCommutativeSymmetricFunctions(UniqueRepresentation, Parent):
sage: TestSuite(complete).run()
"""

def __init__(self, R):
def __init__(self, R) -> None:
r"""
TESTS::

Expand Down Expand Up @@ -445,7 +445,7 @@ def __init__(self, R):
Phi.algebra_morphism(Phi._to_complete_on_generators,
codomain=complete).register_as_coercion()

def _repr_(self): # could be taken care of by the category
def _repr_(self) -> str: # could be taken care of by the category
r"""
EXAMPLES::

Expand All @@ -472,7 +472,8 @@ def a_realization(self):
"""
return self.complete()

_shorthands = tuple(['S', 'R', 'L', 'Phi', 'Psi', 'nM', 'I', 'dQS', 'dYQS', 'ZL', 'ZR'])
_shorthands = ('S', 'R', 'L', 'Phi', 'Psi', 'nM', 'I',
'dQS', 'dYQS', 'ZL', 'ZR')

def dual(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/ncsf_qsym/qsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ class QuasiSymmetricFunctions(UniqueRepresentation, Parent):
True
"""

def __init__(self, R):
def __init__(self, R) -> None:
"""
The Hopf algebra of quasi-symmetric functions.
See ``QuasiSymmetricFunctions`` for full documentation.
Expand Down Expand Up @@ -609,7 +609,7 @@ def __init__(self, R):
codomain=Fundamental, category=category)
Sym_s_to_F.register_as_coercion()

def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

Expand All @@ -632,7 +632,7 @@ def a_realization(self):
"""
return self.Monomial()

_shorthands = tuple(['M', 'F', 'E', 'dI', 'QS', 'YQS', 'phi', 'psi'])
_shorthands = ('M', 'F', 'E', 'dI', 'QS', 'YQS', 'phi', 'psi')

def dual(self):
r"""
Expand Down
6 changes: 3 additions & 3 deletions src/sage/combinat/ncsym/ncsym.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class SymmetricFunctionsNonCommutingVariables(UniqueRepresentation, Parent):
-4*p[] + 2*p[1] + p[2, 2]
"""

def __init__(self, R):
def __init__(self, R) -> None:
"""
Initialize ``self``.

Expand All @@ -309,7 +309,7 @@ def __init__(self, R):
category = GradedHopfAlgebras(R).Cocommutative()
Parent.__init__(self, category=category.WithRealizations())

def _repr_(self):
def _repr_(self) -> str:
r"""
EXAMPLES::

Expand All @@ -331,7 +331,7 @@ def a_realization(self):
"""
return self.powersum()

_shorthands = tuple(['chi', 'cp', 'm', 'e', 'h', 'p', 'rho', 'x'])
_shorthands = ('chi', 'cp', 'm', 'e', 'h', 'p', 'rho', 'x')

def dual(self):
r"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/combinat/sf/sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,8 +1430,8 @@ def register_isomorphism(self, morphism, only_conversion=False):
else:
morphism.codomain().register_coercion(morphism)

_shorthands = ['e', 'f', 'h', 'm', 'p', 's']
_shorthands_all = sorted(_shorthands + ['ht', 'o', 'sp', 'st', 'w'])
_shorthands = ('e', 'f', 'h', 'm', 'p', 's')
_shorthands_all = tuple(sorted(_shorthands + ('ht', 'o', 'sp', 'st', 'w')))

def __init_extra__(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/integer_valued_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class IntegerValuedPolynomialRing(UniqueRepresentation, Parent):
...
TypeError: argument R must be a commutative ring
"""
def __init__(self, R):
def __init__(self, R) -> None:
"""
TESTS::

Expand All @@ -88,7 +88,7 @@ def __init__(self, R):
cat = Algebras(R).Commutative().WithBasis()
Parent.__init__(self, base=R, category=cat.WithRealizations())

_shorthands = ["B", "S"]
_shorthands = ("B", "S")

def _repr_(self) -> str:
r"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/q_integer_valued_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __init__(self, R, q) -> None:
cat = Algebras(R).Commutative().WithBasis()
Parent.__init__(self, base=R, category=cat.WithRealizations())

_shorthands = ["B", "S"]
_shorthands = ("B", "S")

def _repr_(self) -> str:
r"""
Expand Down
Loading