Skip to content

reflections

tergite_autocalibration.utils.misc.reflections

Classes:

Name Description
ASTParser

Parser for the abstract syntax tree. This is to allow inferring more information from

ASTParser

Parser for the abstract syntax tree. This is to allow inferring more information from the sourcecode itself.

Methods:

Name Description
get_init_attribute_names

Returns all the attributes from the init function of a class

get_init_attribute_names staticmethod

get_init_attribute_names() -> Set[str]

Returns all the attributes from the init function of a class

Examples:

1
2
3
4
5
6
7
8
9
>>> class MyClass:
>>>
>>>     def __init__(self):
>>>         self.attr1 = 1
>>>         self.attr2: str = "hello"
>>>
>>> init_attributes = ASTParser.get_init_attribute_names(MyClass)
>>> logger.info(init_attributes)
{'attr1', 'attr2'}

Parameters:

Name Type Description Default
cls Type[Any]

Class to be analysed

required

Returns:

Type Description
Set[str]

Set[str]: The names of the attributes in init as set