How to use get_method_signature_hook method in pandera

Best Python code snippet using pandera_python

plugin.py

Source:plugin.py Github

copy

Full Screen

...95 return None96 def get_function_hook(self, fullname: str97 ) -> Optional[Callable[[FunctionContext], Type]]:98 return None99 def get_method_signature_hook(self, fullname: str100 ) -> Optional[Callable[[MethodSigContext], CallableType]]:101 return None102 def get_method_hook(self, fullname: str103 ) -> Optional[Callable[[MethodContext], Type]]:104 return None105 def get_attribute_hook(self, fullname: str106 ) -> Optional[Callable[[AttributeContext], Type]]:107 return None108 # TODO: metaclass / class decorator hook109T = TypeVar('T')110class ChainedPlugin(Plugin):111 """A plugin that represents a sequence of chained plugins.112 Each lookup method returns the hook for the first plugin that113 reports a match.114 This class should not be subclassed -- use Plugin as the base class115 for all plugins.116 """117 # TODO: Support caching of lookup results (through a LRU cache, for example).118 def __init__(self, options: Options, plugins: List[Plugin]) -> None:119 """Initialize chained plugin.120 Assume that the child plugins aren't mutated (results may be cached).121 """122 super().__init__(options)123 self._plugins = plugins124 def get_type_analyze_hook(self, fullname: str125 ) -> Optional[Callable[[AnalyzeTypeContext], Type]]:126 return self._find_hook(lambda plugin: plugin.get_type_analyze_hook(fullname))127 def get_function_hook(self, fullname: str128 ) -> Optional[Callable[[FunctionContext], Type]]:129 return self._find_hook(lambda plugin: plugin.get_function_hook(fullname))130 def get_method_signature_hook(self, fullname: str131 ) -> Optional[Callable[[MethodSigContext], CallableType]]:132 return self._find_hook(lambda plugin: plugin.get_method_signature_hook(fullname))133 def get_method_hook(self, fullname: str134 ) -> Optional[Callable[[MethodContext], Type]]:135 return self._find_hook(lambda plugin: plugin.get_method_hook(fullname))136 def get_attribute_hook(self, fullname: str137 ) -> Optional[Callable[[AttributeContext], Type]]:138 return self._find_hook(lambda plugin: plugin.get_attribute_hook(fullname))139 def _find_hook(self, lookup: Callable[[Plugin], T]) -> Optional[T]:140 for plugin in self._plugins:141 hook = lookup(plugin)142 if hook:143 return hook144 return None145class DefaultPlugin(Plugin):146 """Type checker plugin that is enabled by default."""147 def get_function_hook(self, fullname: str148 ) -> Optional[Callable[[FunctionContext], Type]]:149 if fullname == 'contextlib.contextmanager':150 return contextmanager_callback151 elif fullname == 'builtins.open' and self.python_version[0] == 3:152 return open_callback153 return None154 def get_method_signature_hook(self, fullname: str155 ) -> Optional[Callable[[MethodSigContext], CallableType]]:156 if fullname == 'typing.Mapping.get':157 return typed_dict_get_signature_callback158 return None159 def get_method_hook(self, fullname: str160 ) -> Optional[Callable[[MethodContext], Type]]:161 if fullname == 'typing.Mapping.get':162 return typed_dict_get_callback163 elif fullname == 'builtins.int.__pow__':164 return int_pow_callback165 return None166def open_callback(ctx: FunctionContext) -> Type:167 """Infer a better return type for 'open'.168 Infer TextIO or BinaryIO as the return value if the mode argument is not...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful