Reference

typin_cli

types

Created on 17 Jul 2017

@author: paulross

class typin.types.FunctionTypes(signature=None)[source]

Class that accumulate function call data such as call arguments, return values and exceptions raised.

add_call(arg_info, file_path, line_number)[source]

Adds a function call from the frame.

add_exception(exception, line_number)[source]

Add an exception.

add_return(return_value, line_number)[source]

Records a return value at a particular line number. If the return_value is None and we have previously seen an exception at this line then this is a phantom return value and must be ignored. See TypeInferencer.__enter__ for a description of this.

argument_type_strings

A collections.OrderedDict of {argument_name : set(types, ...), ...} where the types are strings.

docstring(include_returns, style='sphinx')[source]

Returns a pair (line_number, docstring) for this function. The docstring is the __doc__ for the function and the line_number is the docstring position (function declaration + 1). So to insert into a list of lines called src:

src[:line_number] + docstring.split('\n') + src[line_number:]

style can be: ‘sphinx’, ‘google’.

Raises:TypesExceptionBase or derived class.
exception_type_strings

A dict of {line_number : set(types, ...), ...} for any exceptions raised where the return types are strings. There should only be one type in the set.

filtered_arguments()[source]

A collections.OrderedDict of {argument_name : set(types, ...), ...} where the types are strings. This removes the ‘self’ argument if it is the first argument.

has_self_first_arg()[source]

Returns True if ‘self’ is the first argument i.e. I am a method.

line_decl

Line number of the function declaration as an integer.

Returns:int – Function declaration line.
Raises:FunctionTypesExceptionNoData If there is no entry points recorded.
line_range

A pair of line numbers of the span of the function as integers. The first is the declaration of the function, the last is the extreme return point or exception.

num_entry_points

The number of entry points, 1 for normal functions >1 for generators. 0 Something wrong.

return_type_strings

A dict of {line_number : set(types, ...), ...} for the return values where the return types are strings. There should only be one type in the set.

stub_file_str()[source]

A string suitable for writing to a stub file. Example:

def encodebytes(s: bytes) -> bytes: ...
types_of_self()[source]

Returns the set of types (as strings) as seen for the type of ‘self’. Returns None if ‘self’ is not the first argument i.e. I am not a method.

exception typin.types.FunctionTypesExceptionNoData[source]

Exception thrown when no call date has been added to a FunctionTypes object.

class typin.types.Type(obj, _Type__ids=None)[source]

This class holds type information extracted from a single object. For sequences and so on this will contain a sequence of types.

exception typin.types.TypesExceptionBase[source]

Base class for exceptions thrown by the types module.

type_inferencer