1
0
Fork 0

Merging upstream version 18.2.0.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-13 20:58:22 +01:00
parent 985db29269
commit 53cf4a81a6
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
124 changed files with 60313 additions and 50346 deletions

View file

@ -33,6 +33,15 @@ class AutoName(Enum):
return name
class classproperty(property):
"""
Similar to a normal property but works for class methods
"""
def __get__(self, obj: t.Any, owner: t.Any = None) -> t.Any:
return classmethod(self.fget).__get__(None, owner)() # type: ignore
def seq_get(seq: t.Sequence[T], index: int) -> t.Optional[T]:
"""Returns the value in `seq` at position `index`, or `None` if `index` is out of bounds."""
try:
@ -137,9 +146,9 @@ def subclasses(
def apply_index_offset(
this: exp.Expression,
expressions: t.List[t.Optional[E]],
expressions: t.List[E],
offset: int,
) -> t.List[t.Optional[E]]:
) -> t.List[E]:
"""
Applies an offset to a given integer literal expression.
@ -170,15 +179,14 @@ def apply_index_offset(
):
return expressions
if expression:
if not expression.type:
annotate_types(expression)
if t.cast(exp.DataType, expression.type).this in exp.DataType.INTEGER_TYPES:
logger.warning("Applying array index offset (%s)", offset)
expression = simplify(
exp.Add(this=expression.copy(), expression=exp.Literal.number(offset))
)
return [expression]
if not expression.type:
annotate_types(expression)
if t.cast(exp.DataType, expression.type).this in exp.DataType.INTEGER_TYPES:
logger.warning("Applying array index offset (%s)", offset)
expression = simplify(
exp.Add(this=expression.copy(), expression=exp.Literal.number(offset))
)
return [expression]
return expressions