class documentation

class NewTypeAnalyzer: (source)

View In Hierarchy

Undocumented

Method __init__ Undocumented
Method analyze_newtype_declaration Return the NewType call expression if `s` is a newtype declaration or None otherwise.
Method build_newtype_typeinfo Undocumented
Method check_newtype_args Ananlyze base type in NewType call.
Method fail Undocumented
Method make_argument Undocumented
Method process_newtype_declaration Check if s declares a NewType; if yes, store it in symbol table.
Instance Variable api Undocumented
Instance Variable msg Undocumented
Instance Variable options Undocumented
def __init__(self, options: Options, api: SemanticAnalyzerInterface, msg: MessageBuilder): (source)

Undocumented

def analyze_newtype_declaration(self, s: AssignmentStmt) -> tuple[str|None, CallExpr|None]: (source)

Return the NewType call expression if `s` is a newtype declaration or None otherwise.

def build_newtype_typeinfo(self, name: str, old_type: Type, base_type: Instance, line: int, existing_info: TypeInfo|None) -> TypeInfo: (source)

Undocumented

def check_newtype_args(self, name: str, call: CallExpr, context: Context) -> tuple[Type|None, bool]: (source)

Ananlyze base type in NewType call. Return a tuple (type, should defer).

def fail(self, msg: str, ctx: Context, *, code: ErrorCode|None = None): (source)

Undocumented

def make_argument(self, name: str, type: Type) -> Argument: (source)

Undocumented

def process_newtype_declaration(self, s: AssignmentStmt) -> bool: (source)

Check if s declares a NewType; if yes, store it in symbol table. Return True if it's a NewType declaration. The current target may be deferred as a side effect if the base type is not ready, even if the return value is True. The logic in this function mostly copies the logic for visit_class_def() with a single (non-Generic) base.

Undocumented

Undocumented

Undocumented