stubber.codemod.add_method ========================== .. py:module:: stubber.codemod.add_method .. autoapi-nested-parse:: Codemod to add methods to a classes. Used to add methods that are documented, but are not reported by the firmware, so they are also not present in the firmware stubs. Classes ------- .. autoapisummary:: stubber.codemod.add_method.CallFinder stubber.codemod.add_method.CallAdder Module Contents --------------- .. py:class:: CallFinder Bases: :py:obj:`libcst.matchers.MatcherDecoratableTransformer` Find the Pin.__call__ method and extract it from a (machine) module. .. py:attribute:: class_name :type: str :value: 'Pin' .. py:attribute:: method_name :type: str :value: '__call__' .. py:attribute:: call_meth :type: Optional[libcst.FunctionDef] :value: None .. py:method:: detect_call(node: libcst.FunctionDef) -> None find the __call__ method and store it. .. py:class:: CallAdder(call_meth: libcst.FunctionDef) Bases: :py:obj:`libcst.matchers.MatcherDecoratableTransformer` Add a __call__ method to a class if it is missing. .. py:attribute:: class_name :value: 'Pin' .. py:attribute:: has_call :value: 0 .. py:attribute:: call_meth .. py:method:: detect_call(node: libcst.FunctionDef) -> None Detect if the class already has a __call__ method. .. py:method:: add_call(original_node: libcst.ClassDef, updated_node: libcst.ClassDef) -> libcst.ClassDef Add the __call__ method to the class if it is not already there.