irx.analysis.types
irx.analysis.types
Source: packages/irx/src/irx/analysis/types.py
title: Type helpers for semantic analysis.
summary: >-
Provide the small AST-type predicates and promotion helpers that the semantic
analyzer reuses across many node visitors.Functions
requires_size_check(target_size: int | None, value_size: int | None) -> bool
title: Return whether assignment requires a runtime size check.
parameters:
target_size:
type: int | None
value_size:
type: int | None
returns:
type: boolrequires_shape_check(target_shape: tuple[int, ...] | None, value_shape: tuple[int, ...] | None) -> bool
title: Return whether assignment requires a runtime shape check.
parameters:
target_shape:
type: tuple[int, Ellipsis] | None
value_shape:
type: tuple[int, Ellipsis] | None
returns:
type: boolclone_type(type_: astx.DataType) -> astx.DataType
title: Clone an AST type by class.
parameters:
type_:
type: astx.DataType
returns:
type: astx.DataTypedisplay_type_name(type_: astx.DataType | None) -> str
title: Return one stable human-facing type name.
parameters:
type_:
type: astx.DataType | None
returns:
type: strsame_type(lhs: astx.DataType | None, rhs: astx.DataType | None) -> bool
title: Return whether two AST types share the same class.
parameters:
lhs:
type: astx.DataType | None
rhs:
type: astx.DataType | None
returns:
type: boolis_integer_type(type_: astx.DataType | None) -> bool
title: Is integer type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_signed_integer_type(type_: astx.DataType | None) -> bool
title: Is signed integer type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_unsigned_type(type_: astx.DataType | None) -> bool
title: Is unsigned type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_float_type(type_: astx.DataType | None) -> bool
title: Is float type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_numeric_type(type_: astx.DataType | None) -> bool
title: Is numeric type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_boolean_type(type_: astx.DataType | None) -> bool
title: Is boolean type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_string_type(type_: astx.DataType | None) -> bool
title: Is string type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_temporal_type(type_: astx.DataType | None) -> bool
title: Is temporal type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_none_type(type_: astx.DataType | None) -> bool
title: Is none type.
parameters:
type_:
type: astx.DataType | None
returns:
type: boolis_type_member(target: astx.DataType | None, value: astx.DataType | None) -> bool
title: Return whether a value type is a member of a target type.
parameters:
target:
type: astx.DataType | None
value:
type: astx.DataType | None
returns:
type: boolbit_width(type_: astx.DataType | None) -> int
title: Return the nominal bit width for numeric types.
parameters:
type_:
type: astx.DataType | None
returns:
type: intfloat_promotion_width_for_integer_width(width: int) -> int
title: Return the float width floor used when integers promote with floats.
parameters:
width:
type: int
returns:
type: intcommon_numeric_type(lhs: astx.DataType | None, rhs: astx.DataType | None) -> astx.DataType | None
title: Return a widened numeric type shared by both operands.
parameters:
lhs:
type: astx.DataType | None
rhs:
type: astx.DataType | None
returns:
type: astx.DataType | Noneis_explicitly_castable(source: astx.DataType | None, target: astx.DataType | None) -> bool
title: Return whether an explicit Cast expression is allowed.
parameters:
source:
type: astx.DataType | None
target:
type: astx.DataType | None
returns:
type: boolis_assignable(target: astx.DataType | None, value: astx.DataType | None) -> bool
title: Return whether a value type can be assigned to a target type.
parameters:
target:
type: astx.DataType | None
value:
type: astx.DataType | None
returns:
type: bool