Best Python code snippet using pytest-benchmark
error_type_conversion_methods.py
Source:error_type_conversion_methods.py
...129: r1 = math.pow(Empty(), 3) # Error: No __float__ method1310: 1411: 1512: class Ops:1613: def __float__(self):1714: return 3 # Don't return a float (even if the type promotes to float, a runtime error is reported1815: 1916: 2017: r2 = math.pow(Ops(), 3) # Wrong __float__ (type conversion) method, not detected, runtime error2118: 2219: 2320: class WrongOps:2421: def __float__(self):2522: return "not a float"2623: 2724: 2825: r3 = math.pow(WrongOps(), 3) # Runtime error, not reported2926: 3027: 3128: class EvenMoreWrongOps:3229: def __float__(self, extra):3330: return 3.03431: 3532: 3633: r4 = math.pow(EvenMoreWrongOps(), 3) # Not reported, even if the problem is parameter arity3734: 3835: 3936: class RightOps:4037: def __float__(self):4138: return 3.04239: 4340: 4441: r5 = math.pow(RightOps(), 3)4542: 46"""47# Import the stypy library necessary elements48from stypy.type_inference_programs.type_inference_programs_imports import *49# Create the module type store50module_type_store = Context(None, __file__)51# ################# Begin of the type inference program ##################52stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 1, 0))53# 'import math' statement (line 1)54import math55import_module(stypy.reporting.localization.Localization(__file__, 1, 0), 'math', math, module_type_store)56# Declaration of the 'Empty' class57class Empty:58 @norecursion59 def __init__(type_of_self, localization, *varargs, **kwargs):60 global module_type_store61 # Assign values to the parameters with defaults62 defaults = []63 # Create a new context for function '__init__'64 module_type_store = module_type_store.open_function_context('__init__', 5, 4, False)65 # Assigning a type to the variable 'self' (line 6)66 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 6, 4), 'self', type_of_self)67 68 # Passed parameters checking function69 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Empty.__init__', [], None, None, defaults, varargs, kwargs)70 if is_error_type(arguments):71 # Destroy the current context72 module_type_store = module_type_store.close_function_context()73 return74 # Initialize method data75 init_call_information(module_type_store, '__init__', localization, [], arguments)76 77 # Default return type storage variable (SSA)78 # Assigning a type to the variable 'stypy_return_type'79 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)80 81 82 # ################# Begin of '__init__(...)' code ##################83 pass84 85 # ################# End of '__init__(...)' code ##################86 # Teardown call information87 teardown_call_information(localization, arguments)88 # Destroy the current context89 module_type_store = module_type_store.close_function_context()90# Assigning a type to the variable 'Empty' (line 4)91module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 4, 0), 'Empty', Empty)92# Assigning a Call to a Name (line 9):93# Call to pow(...): (line 9)94# Processing the call arguments (line 9)95# Call to Empty(...): (line 9)96# Processing the call keyword arguments (line 9)97kwargs_8040 = {}98# Getting the type of 'Empty' (line 9)99Empty_8039 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 9, 14), 'Empty', False)100# Calling Empty(args, kwargs) (line 9)101Empty_call_result_8041 = invoke(stypy.reporting.localization.Localization(__file__, 9, 14), Empty_8039, *[], **kwargs_8040)102int_8042 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 9, 23), 'int')103# Processing the call keyword arguments (line 9)104kwargs_8043 = {}105# Getting the type of 'math' (line 9)106math_8037 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 9, 5), 'math', False)107# Obtaining the member 'pow' of a type (line 9)108pow_8038 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 9, 5), math_8037, 'pow')109# Calling pow(args, kwargs) (line 9)110pow_call_result_8044 = invoke(stypy.reporting.localization.Localization(__file__, 9, 5), pow_8038, *[Empty_call_result_8041, int_8042], **kwargs_8043)111# Assigning a type to the variable 'r1' (line 9)112module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 9, 0), 'r1', pow_call_result_8044)113# Declaration of the 'Ops' class114class Ops:115 @norecursion116 def __float__(type_of_self, localization, *varargs, **kwargs):117 global module_type_store118 # Assign values to the parameters with defaults119 defaults = []120 # Create a new context for function '__float__'121 module_type_store = module_type_store.open_function_context('__float__', 13, 4, False)122 # Assigning a type to the variable 'self' (line 14)123 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 14, 4), 'self', type_of_self)124 125 # Passed parameters checking function126 Ops.__float__.__dict__.__setitem__('stypy_localization', localization)127 Ops.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)128 Ops.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)129 Ops.__float__.__dict__.__setitem__('stypy_function_name', 'Ops.__float__')130 Ops.__float__.__dict__.__setitem__('stypy_param_names_list', [])131 Ops.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)132 Ops.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)133 Ops.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)134 Ops.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)135 Ops.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)136 Ops.__float__.__dict__.__setitem__('stypy_declared_arg_number', 1)137 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Ops.__float__', [], None, None, defaults, varargs, kwargs)138 if is_error_type(arguments):139 # Destroy the current context140 module_type_store = module_type_store.close_function_context()141 return arguments142 # Initialize method data143 init_call_information(module_type_store, '__float__', localization, [], arguments)144 145 # Default return type storage variable (SSA)146 # Assigning a type to the variable 'stypy_return_type'147 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)148 149 150 # ################# Begin of '__float__(...)' code ##################151 int_8045 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 14, 15), 'int')152 # Assigning a type to the variable 'stypy_return_type' (line 14)153 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 14, 8), 'stypy_return_type', int_8045)154 155 # ################# End of '__float__(...)' code ##################156 # Teardown call information157 teardown_call_information(localization, arguments)158 159 # Storing the return type of function '__float__' in the type store160 # Getting the type of 'stypy_return_type' (line 13)161 stypy_return_type_8046 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 13, 4), 'stypy_return_type')162 module_type_store.store_return_type_of_current_context(stypy_return_type_8046)163 164 # Destroy the current context165 module_type_store = module_type_store.close_function_context()166 167 # Return type of the function '__float__'168 return stypy_return_type_8046169 @norecursion170 def __init__(type_of_self, localization, *varargs, **kwargs):171 global module_type_store172 # Assign values to the parameters with defaults173 defaults = []174 # Create a new context for function '__init__'175 module_type_store = module_type_store.open_function_context('__init__', 12, 0, False)176 # Assigning a type to the variable 'self' (line 13)177 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 13, 0), 'self', type_of_self)178 179 # Passed parameters checking function180 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Ops.__init__', [], None, None, defaults, varargs, kwargs)181 if is_error_type(arguments):182 # Destroy the current context183 module_type_store = module_type_store.close_function_context()184 return185 # Initialize method data186 init_call_information(module_type_store, '__init__', localization, [], arguments)187 188 # Default return type storage variable (SSA)189 # Assigning a type to the variable 'stypy_return_type'190 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)191 192 193 # ################# Begin of '__init__(...)' code ##################194 pass195 196 # ################# End of '__init__(...)' code ##################197 # Teardown call information198 teardown_call_information(localization, arguments)199 # Destroy the current context200 module_type_store = module_type_store.close_function_context()201# Assigning a type to the variable 'Ops' (line 12)202module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 12, 0), 'Ops', Ops)203# Assigning a Call to a Name (line 17):204# Call to pow(...): (line 17)205# Processing the call arguments (line 17)206# Call to Ops(...): (line 17)207# Processing the call keyword arguments (line 17)208kwargs_8050 = {}209# Getting the type of 'Ops' (line 17)210Ops_8049 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 17, 14), 'Ops', False)211# Calling Ops(args, kwargs) (line 17)212Ops_call_result_8051 = invoke(stypy.reporting.localization.Localization(__file__, 17, 14), Ops_8049, *[], **kwargs_8050)213int_8052 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 17, 21), 'int')214# Processing the call keyword arguments (line 17)215kwargs_8053 = {}216# Getting the type of 'math' (line 17)217math_8047 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 17, 5), 'math', False)218# Obtaining the member 'pow' of a type (line 17)219pow_8048 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 17, 5), math_8047, 'pow')220# Calling pow(args, kwargs) (line 17)221pow_call_result_8054 = invoke(stypy.reporting.localization.Localization(__file__, 17, 5), pow_8048, *[Ops_call_result_8051, int_8052], **kwargs_8053)222# Assigning a type to the variable 'r2' (line 17)223module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 17, 0), 'r2', pow_call_result_8054)224# Declaration of the 'WrongOps' class225class WrongOps:226 @norecursion227 def __float__(type_of_self, localization, *varargs, **kwargs):228 global module_type_store229 # Assign values to the parameters with defaults230 defaults = []231 # Create a new context for function '__float__'232 module_type_store = module_type_store.open_function_context('__float__', 21, 4, False)233 # Assigning a type to the variable 'self' (line 22)234 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 22, 4), 'self', type_of_self)235 236 # Passed parameters checking function237 WrongOps.__float__.__dict__.__setitem__('stypy_localization', localization)238 WrongOps.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)239 WrongOps.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)240 WrongOps.__float__.__dict__.__setitem__('stypy_function_name', 'WrongOps.__float__')241 WrongOps.__float__.__dict__.__setitem__('stypy_param_names_list', [])242 WrongOps.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)243 WrongOps.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)244 WrongOps.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)245 WrongOps.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)246 WrongOps.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)247 WrongOps.__float__.__dict__.__setitem__('stypy_declared_arg_number', 1)248 arguments = process_argument_values(localization, type_of_self, module_type_store, 'WrongOps.__float__', [], None, None, defaults, varargs, kwargs)249 if is_error_type(arguments):250 # Destroy the current context251 module_type_store = module_type_store.close_function_context()252 return arguments253 # Initialize method data254 init_call_information(module_type_store, '__float__', localization, [], arguments)255 256 # Default return type storage variable (SSA)257 # Assigning a type to the variable 'stypy_return_type'258 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)259 260 261 # ################# Begin of '__float__(...)' code ##################262 str_8055 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 22, 15), 'str', 'not a float')263 # Assigning a type to the variable 'stypy_return_type' (line 22)264 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 22, 8), 'stypy_return_type', str_8055)265 266 # ################# End of '__float__(...)' code ##################267 # Teardown call information268 teardown_call_information(localization, arguments)269 270 # Storing the return type of function '__float__' in the type store271 # Getting the type of 'stypy_return_type' (line 21)272 stypy_return_type_8056 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 21, 4), 'stypy_return_type')273 module_type_store.store_return_type_of_current_context(stypy_return_type_8056)274 275 # Destroy the current context276 module_type_store = module_type_store.close_function_context()277 278 # Return type of the function '__float__'279 return stypy_return_type_8056280 @norecursion281 def __init__(type_of_self, localization, *varargs, **kwargs):282 global module_type_store283 # Assign values to the parameters with defaults284 defaults = []285 # Create a new context for function '__init__'286 module_type_store = module_type_store.open_function_context('__init__', 20, 0, False)287 # Assigning a type to the variable 'self' (line 21)288 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 21, 0), 'self', type_of_self)289 290 # Passed parameters checking function291 arguments = process_argument_values(localization, type_of_self, module_type_store, 'WrongOps.__init__', [], None, None, defaults, varargs, kwargs)292 if is_error_type(arguments):293 # Destroy the current context294 module_type_store = module_type_store.close_function_context()295 return296 # Initialize method data297 init_call_information(module_type_store, '__init__', localization, [], arguments)298 299 # Default return type storage variable (SSA)300 # Assigning a type to the variable 'stypy_return_type'301 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)302 303 304 # ################# Begin of '__init__(...)' code ##################305 pass306 307 # ################# End of '__init__(...)' code ##################308 # Teardown call information309 teardown_call_information(localization, arguments)310 # Destroy the current context311 module_type_store = module_type_store.close_function_context()312# Assigning a type to the variable 'WrongOps' (line 20)313module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 20, 0), 'WrongOps', WrongOps)314# Assigning a Call to a Name (line 25):315# Call to pow(...): (line 25)316# Processing the call arguments (line 25)317# Call to WrongOps(...): (line 25)318# Processing the call keyword arguments (line 25)319kwargs_8060 = {}320# Getting the type of 'WrongOps' (line 25)321WrongOps_8059 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 25, 14), 'WrongOps', False)322# Calling WrongOps(args, kwargs) (line 25)323WrongOps_call_result_8061 = invoke(stypy.reporting.localization.Localization(__file__, 25, 14), WrongOps_8059, *[], **kwargs_8060)324int_8062 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 25, 26), 'int')325# Processing the call keyword arguments (line 25)326kwargs_8063 = {}327# Getting the type of 'math' (line 25)328math_8057 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 25, 5), 'math', False)329# Obtaining the member 'pow' of a type (line 25)330pow_8058 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 25, 5), math_8057, 'pow')331# Calling pow(args, kwargs) (line 25)332pow_call_result_8064 = invoke(stypy.reporting.localization.Localization(__file__, 25, 5), pow_8058, *[WrongOps_call_result_8061, int_8062], **kwargs_8063)333# Assigning a type to the variable 'r3' (line 25)334module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 25, 0), 'r3', pow_call_result_8064)335# Declaration of the 'EvenMoreWrongOps' class336class EvenMoreWrongOps:337 @norecursion338 def __float__(type_of_self, localization, *varargs, **kwargs):339 global module_type_store340 # Assign values to the parameters with defaults341 defaults = []342 # Create a new context for function '__float__'343 module_type_store = module_type_store.open_function_context('__float__', 29, 4, False)344 # Assigning a type to the variable 'self' (line 30)345 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 30, 4), 'self', type_of_self)346 347 # Passed parameters checking function348 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_localization', localization)349 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)350 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)351 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_function_name', 'EvenMoreWrongOps.__float__')352 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_param_names_list', ['extra'])353 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)354 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)355 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)356 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)357 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)358 EvenMoreWrongOps.__float__.__dict__.__setitem__('stypy_declared_arg_number', 2)359 arguments = process_argument_values(localization, type_of_self, module_type_store, 'EvenMoreWrongOps.__float__', ['extra'], None, None, defaults, varargs, kwargs)360 if is_error_type(arguments):361 # Destroy the current context362 module_type_store = module_type_store.close_function_context()363 return arguments364 # Initialize method data365 init_call_information(module_type_store, '__float__', localization, ['extra'], arguments)366 367 # Default return type storage variable (SSA)368 # Assigning a type to the variable 'stypy_return_type'369 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)370 371 372 # ################# Begin of '__float__(...)' code ##################373 float_8065 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 30, 15), 'float')374 # Assigning a type to the variable 'stypy_return_type' (line 30)375 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 30, 8), 'stypy_return_type', float_8065)376 377 # ################# End of '__float__(...)' code ##################378 # Teardown call information379 teardown_call_information(localization, arguments)380 381 # Storing the return type of function '__float__' in the type store382 # Getting the type of 'stypy_return_type' (line 29)383 stypy_return_type_8066 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 29, 4), 'stypy_return_type')384 module_type_store.store_return_type_of_current_context(stypy_return_type_8066)385 386 # Destroy the current context387 module_type_store = module_type_store.close_function_context()388 389 # Return type of the function '__float__'390 return stypy_return_type_8066391 @norecursion392 def __init__(type_of_self, localization, *varargs, **kwargs):393 global module_type_store394 # Assign values to the parameters with defaults395 defaults = []396 # Create a new context for function '__init__'397 module_type_store = module_type_store.open_function_context('__init__', 28, 0, False)398 # Assigning a type to the variable 'self' (line 29)399 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 29, 0), 'self', type_of_self)400 401 # Passed parameters checking function402 arguments = process_argument_values(localization, type_of_self, module_type_store, 'EvenMoreWrongOps.__init__', [], None, None, defaults, varargs, kwargs)403 if is_error_type(arguments):404 # Destroy the current context405 module_type_store = module_type_store.close_function_context()406 return407 # Initialize method data408 init_call_information(module_type_store, '__init__', localization, [], arguments)409 410 # Default return type storage variable (SSA)411 # Assigning a type to the variable 'stypy_return_type'412 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)413 414 415 # ################# Begin of '__init__(...)' code ##################416 pass417 418 # ################# End of '__init__(...)' code ##################419 # Teardown call information420 teardown_call_information(localization, arguments)421 # Destroy the current context422 module_type_store = module_type_store.close_function_context()423# Assigning a type to the variable 'EvenMoreWrongOps' (line 28)424module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 28, 0), 'EvenMoreWrongOps', EvenMoreWrongOps)425# Assigning a Call to a Name (line 33):426# Call to pow(...): (line 33)427# Processing the call arguments (line 33)428# Call to EvenMoreWrongOps(...): (line 33)429# Processing the call keyword arguments (line 33)430kwargs_8070 = {}431# Getting the type of 'EvenMoreWrongOps' (line 33)432EvenMoreWrongOps_8069 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 33, 14), 'EvenMoreWrongOps', False)433# Calling EvenMoreWrongOps(args, kwargs) (line 33)434EvenMoreWrongOps_call_result_8071 = invoke(stypy.reporting.localization.Localization(__file__, 33, 14), EvenMoreWrongOps_8069, *[], **kwargs_8070)435int_8072 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 33, 34), 'int')436# Processing the call keyword arguments (line 33)437kwargs_8073 = {}438# Getting the type of 'math' (line 33)439math_8067 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 33, 5), 'math', False)440# Obtaining the member 'pow' of a type (line 33)441pow_8068 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 33, 5), math_8067, 'pow')442# Calling pow(args, kwargs) (line 33)443pow_call_result_8074 = invoke(stypy.reporting.localization.Localization(__file__, 33, 5), pow_8068, *[EvenMoreWrongOps_call_result_8071, int_8072], **kwargs_8073)444# Assigning a type to the variable 'r4' (line 33)445module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 33, 0), 'r4', pow_call_result_8074)446# Declaration of the 'RightOps' class447class RightOps:448 @norecursion449 def __float__(type_of_self, localization, *varargs, **kwargs):450 global module_type_store451 # Assign values to the parameters with defaults452 defaults = []453 # Create a new context for function '__float__'454 module_type_store = module_type_store.open_function_context('__float__', 37, 4, False)455 # Assigning a type to the variable 'self' (line 38)456 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 38, 4), 'self', type_of_self)457 458 # Passed parameters checking function459 RightOps.__float__.__dict__.__setitem__('stypy_localization', localization)460 RightOps.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)461 RightOps.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)462 RightOps.__float__.__dict__.__setitem__('stypy_function_name', 'RightOps.__float__')463 RightOps.__float__.__dict__.__setitem__('stypy_param_names_list', [])464 RightOps.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)465 RightOps.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)466 RightOps.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)467 RightOps.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)468 RightOps.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)469 RightOps.__float__.__dict__.__setitem__('stypy_declared_arg_number', 1)470 arguments = process_argument_values(localization, type_of_self, module_type_store, 'RightOps.__float__', [], None, None, defaults, varargs, kwargs)471 if is_error_type(arguments):472 # Destroy the current context473 module_type_store = module_type_store.close_function_context()474 return arguments475 # Initialize method data476 init_call_information(module_type_store, '__float__', localization, [], arguments)477 478 # Default return type storage variable (SSA)479 # Assigning a type to the variable 'stypy_return_type'480 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)481 482 483 # ################# Begin of '__float__(...)' code ##################484 float_8075 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 38, 15), 'float')485 # Assigning a type to the variable 'stypy_return_type' (line 38)486 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 38, 8), 'stypy_return_type', float_8075)487 488 # ################# End of '__float__(...)' code ##################489 # Teardown call information490 teardown_call_information(localization, arguments)491 492 # Storing the return type of function '__float__' in the type store493 # Getting the type of 'stypy_return_type' (line 37)494 stypy_return_type_8076 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 37, 4), 'stypy_return_type')495 module_type_store.store_return_type_of_current_context(stypy_return_type_8076)496 497 # Destroy the current context498 module_type_store = module_type_store.close_function_context()499 500 # Return type of the function '__float__'501 return stypy_return_type_8076502 @norecursion...
error___ceil__parameters.py
Source:error___ceil__parameters.py
...74: __doc__ = "__ceil__ method is present, but is declared with a wrong number of parameters"85: 96: if __name__ == '__main__':107: class Sample:118: def __float__(self, other, another):129: return 1.01310: 1411: 1512: # Type error1613: print math.ceil(Sample())1714: 1815: 1916: class OtherSample:2017: def __float__(self, other):2118: return 1.02219: 2320: 2421: # Type error2522: print math.ceil(OtherSample())2623: 27"""28# Import the stypy library necessary elements29from stypy.type_inference_programs.type_inference_programs_imports import *30# Create the module type store31module_type_store = Context(None, __file__)32# ################# Begin of the type inference program ##################33stypy.reporting.localization.Localization.set_current(stypy.reporting.localization.Localization(__file__, 2, 0))34# 'import math' statement (line 2)35import math36import_module(stypy.reporting.localization.Localization(__file__, 2, 0), 'math', math, module_type_store)37# Assigning a Str to a Name (line 4):38str_1 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 4, 10), 'str', '__ceil__ method is present, but is declared with a wrong number of parameters')39# Assigning a type to the variable '__doc__' (line 4)40module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 4, 0), '__doc__', str_1)41if (__name__ == '__main__'):42 # Declaration of the 'Sample' class43 class Sample:44 @norecursion45 def __float__(type_of_self, localization, *varargs, **kwargs):46 global module_type_store47 # Assign values to the parameters with defaults48 defaults = []49 # Create a new context for function '__float__'50 module_type_store = module_type_store.open_function_context('__float__', 8, 8, False)51 # Assigning a type to the variable 'self' (line 9)52 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 9, 8), 'self', type_of_self)53 54 # Passed parameters checking function55 Sample.__float__.__dict__.__setitem__('stypy_localization', localization)56 Sample.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)57 Sample.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)58 Sample.__float__.__dict__.__setitem__('stypy_function_name', 'Sample.__float__')59 Sample.__float__.__dict__.__setitem__('stypy_param_names_list', ['other', 'another'])60 Sample.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)61 Sample.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)62 Sample.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)63 Sample.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)64 Sample.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)65 Sample.__float__.__dict__.__setitem__('stypy_declared_arg_number', 3)66 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Sample.__float__', ['other', 'another'], None, None, defaults, varargs, kwargs)67 if is_error_type(arguments):68 # Destroy the current context69 module_type_store = module_type_store.close_function_context()70 return arguments71 # Initialize method data72 init_call_information(module_type_store, '__float__', localization, ['other', 'another'], arguments)73 74 # Default return type storage variable (SSA)75 # Assigning a type to the variable 'stypy_return_type'76 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)77 78 79 # ################# Begin of '__float__(...)' code ##################80 float_2 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 9, 19), 'float')81 # Assigning a type to the variable 'stypy_return_type' (line 9)82 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 9, 12), 'stypy_return_type', float_2)83 84 # ################# End of '__float__(...)' code ##################85 # Teardown call information86 teardown_call_information(localization, arguments)87 88 # Storing the return type of function '__float__' in the type store89 # Getting the type of 'stypy_return_type' (line 8)90 stypy_return_type_3 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 8, 8), 'stypy_return_type')91 module_type_store.store_return_type_of_current_context(stypy_return_type_3)92 93 # Destroy the current context94 module_type_store = module_type_store.close_function_context()95 96 # Return type of the function '__float__'97 return stypy_return_type_398 @norecursion99 def __init__(type_of_self, localization, *varargs, **kwargs):100 global module_type_store101 # Assign values to the parameters with defaults102 defaults = []103 # Create a new context for function '__init__'104 module_type_store = module_type_store.open_function_context('__init__', 7, 4, False)105 # Assigning a type to the variable 'self' (line 8)106 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 8, 4), 'self', type_of_self)107 108 # Passed parameters checking function109 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Sample.__init__', [], None, None, defaults, varargs, kwargs)110 if is_error_type(arguments):111 # Destroy the current context112 module_type_store = module_type_store.close_function_context()113 return114 # Initialize method data115 init_call_information(module_type_store, '__init__', localization, [], arguments)116 117 # Default return type storage variable (SSA)118 # Assigning a type to the variable 'stypy_return_type'119 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)120 121 122 # ################# Begin of '__init__(...)' code ##################123 pass124 125 # ################# End of '__init__(...)' code ##################126 # Teardown call information127 teardown_call_information(localization, arguments)128 # Destroy the current context129 module_type_store = module_type_store.close_function_context()130 131 # Assigning a type to the variable 'Sample' (line 7)132 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 7, 4), 'Sample', Sample)133 134 # Call to ceil(...): (line 13)135 # Processing the call arguments (line 13)136 137 # Call to Sample(...): (line 13)138 # Processing the call keyword arguments (line 13)139 kwargs_7 = {}140 # Getting the type of 'Sample' (line 13)141 Sample_6 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 13, 20), 'Sample', False)142 # Calling Sample(args, kwargs) (line 13)143 Sample_call_result_8 = invoke(stypy.reporting.localization.Localization(__file__, 13, 20), Sample_6, *[], **kwargs_7)144 145 # Processing the call keyword arguments (line 13)146 kwargs_9 = {}147 # Getting the type of 'math' (line 13)148 math_4 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 13, 10), 'math', False)149 # Obtaining the member 'ceil' of a type (line 13)150 ceil_5 = module_type_store.get_type_of_member(stypy.reporting.localization.Localization(__file__, 13, 10), math_4, 'ceil')151 # Calling ceil(args, kwargs) (line 13)152 ceil_call_result_10 = invoke(stypy.reporting.localization.Localization(__file__, 13, 10), ceil_5, *[Sample_call_result_8], **kwargs_9)153 154 # Declaration of the 'OtherSample' class155 class OtherSample:156 @norecursion157 def __float__(type_of_self, localization, *varargs, **kwargs):158 global module_type_store159 # Assign values to the parameters with defaults160 defaults = []161 # Create a new context for function '__float__'162 module_type_store = module_type_store.open_function_context('__float__', 17, 8, False)163 # Assigning a type to the variable 'self' (line 18)164 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 18, 8), 'self', type_of_self)165 166 # Passed parameters checking function167 OtherSample.__float__.__dict__.__setitem__('stypy_localization', localization)168 OtherSample.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)169 OtherSample.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)170 OtherSample.__float__.__dict__.__setitem__('stypy_function_name', 'OtherSample.__float__')171 OtherSample.__float__.__dict__.__setitem__('stypy_param_names_list', ['other'])172 OtherSample.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)173 OtherSample.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)174 OtherSample.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)175 OtherSample.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)176 OtherSample.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)177 OtherSample.__float__.__dict__.__setitem__('stypy_declared_arg_number', 2)178 arguments = process_argument_values(localization, type_of_self, module_type_store, 'OtherSample.__float__', ['other'], None, None, defaults, varargs, kwargs)179 if is_error_type(arguments):180 # Destroy the current context181 module_type_store = module_type_store.close_function_context()182 return arguments183 # Initialize method data184 init_call_information(module_type_store, '__float__', localization, ['other'], arguments)185 186 # Default return type storage variable (SSA)187 # Assigning a type to the variable 'stypy_return_type'188 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)189 190 191 # ################# Begin of '__float__(...)' code ##################192 float_11 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 18, 19), 'float')193 # Assigning a type to the variable 'stypy_return_type' (line 18)194 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 18, 12), 'stypy_return_type', float_11)195 196 # ################# End of '__float__(...)' code ##################197 # Teardown call information198 teardown_call_information(localization, arguments)199 200 # Storing the return type of function '__float__' in the type store201 # Getting the type of 'stypy_return_type' (line 17)202 stypy_return_type_12 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 17, 8), 'stypy_return_type')203 module_type_store.store_return_type_of_current_context(stypy_return_type_12)204 205 # Destroy the current context206 module_type_store = module_type_store.close_function_context()207 208 # Return type of the function '__float__'209 return stypy_return_type_12210 @norecursion...
error___round__parameters.py
Source:error___round__parameters.py
...52: __doc__ = "__round__ method is present, but is declared with a wrong number of parameters"63: 74: if __name__ == '__main__':85: class Sample:96: def __float__(self, other, another):107: return 1.0118: 129: 1310: # Type error1411: print round(Sample())1512: 1613: 1714: class OtherSample:1815: def __float__(self, other):1916: return 1.02017: 2118: 2219: # Type error2320: print round(OtherSample())2421: 25"""26# Import the stypy library necessary elements27from stypy.type_inference_programs.type_inference_programs_imports import *28# Create the module type store29module_type_store = Context(None, __file__)30# ################# Begin of the type inference program ##################31# Assigning a Str to a Name (line 2):32str_1 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 2, 10), 'str', '__round__ method is present, but is declared with a wrong number of parameters')33# Assigning a type to the variable '__doc__' (line 2)34module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 2, 0), '__doc__', str_1)35if (__name__ == '__main__'):36 # Declaration of the 'Sample' class37 class Sample:38 @norecursion39 def __float__(type_of_self, localization, *varargs, **kwargs):40 global module_type_store41 # Assign values to the parameters with defaults42 defaults = []43 # Create a new context for function '__float__'44 module_type_store = module_type_store.open_function_context('__float__', 6, 8, False)45 # Assigning a type to the variable 'self' (line 7)46 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 7, 8), 'self', type_of_self)47 48 # Passed parameters checking function49 Sample.__float__.__dict__.__setitem__('stypy_localization', localization)50 Sample.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)51 Sample.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)52 Sample.__float__.__dict__.__setitem__('stypy_function_name', 'Sample.__float__')53 Sample.__float__.__dict__.__setitem__('stypy_param_names_list', ['other', 'another'])54 Sample.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)55 Sample.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)56 Sample.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)57 Sample.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)58 Sample.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)59 Sample.__float__.__dict__.__setitem__('stypy_declared_arg_number', 3)60 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Sample.__float__', ['other', 'another'], None, None, defaults, varargs, kwargs)61 if is_error_type(arguments):62 # Destroy the current context63 module_type_store = module_type_store.close_function_context()64 return arguments65 # Initialize method data66 init_call_information(module_type_store, '__float__', localization, ['other', 'another'], arguments)67 68 # Default return type storage variable (SSA)69 # Assigning a type to the variable 'stypy_return_type'70 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)71 72 73 # ################# Begin of '__float__(...)' code ##################74 float_2 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 7, 19), 'float')75 # Assigning a type to the variable 'stypy_return_type' (line 7)76 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 7, 12), 'stypy_return_type', float_2)77 78 # ################# End of '__float__(...)' code ##################79 # Teardown call information80 teardown_call_information(localization, arguments)81 82 # Storing the return type of function '__float__' in the type store83 # Getting the type of 'stypy_return_type' (line 6)84 stypy_return_type_3 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 6, 8), 'stypy_return_type')85 module_type_store.store_return_type_of_current_context(stypy_return_type_3)86 87 # Destroy the current context88 module_type_store = module_type_store.close_function_context()89 90 # Return type of the function '__float__'91 return stypy_return_type_392 @norecursion93 def __init__(type_of_self, localization, *varargs, **kwargs):94 global module_type_store95 # Assign values to the parameters with defaults96 defaults = []97 # Create a new context for function '__init__'98 module_type_store = module_type_store.open_function_context('__init__', 5, 4, False)99 # Assigning a type to the variable 'self' (line 6)100 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 6, 4), 'self', type_of_self)101 102 # Passed parameters checking function103 arguments = process_argument_values(localization, type_of_self, module_type_store, 'Sample.__init__', [], None, None, defaults, varargs, kwargs)104 if is_error_type(arguments):105 # Destroy the current context106 module_type_store = module_type_store.close_function_context()107 return108 # Initialize method data109 init_call_information(module_type_store, '__init__', localization, [], arguments)110 111 # Default return type storage variable (SSA)112 # Assigning a type to the variable 'stypy_return_type'113 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)114 115 116 # ################# Begin of '__init__(...)' code ##################117 pass118 119 # ################# End of '__init__(...)' code ##################120 # Teardown call information121 teardown_call_information(localization, arguments)122 # Destroy the current context123 module_type_store = module_type_store.close_function_context()124 125 # Assigning a type to the variable 'Sample' (line 5)126 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 5, 4), 'Sample', Sample)127 128 # Call to round(...): (line 11)129 # Processing the call arguments (line 11)130 131 # Call to Sample(...): (line 11)132 # Processing the call keyword arguments (line 11)133 kwargs_6 = {}134 # Getting the type of 'Sample' (line 11)135 Sample_5 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 11, 16), 'Sample', False)136 # Calling Sample(args, kwargs) (line 11)137 Sample_call_result_7 = invoke(stypy.reporting.localization.Localization(__file__, 11, 16), Sample_5, *[], **kwargs_6)138 139 # Processing the call keyword arguments (line 11)140 kwargs_8 = {}141 # Getting the type of 'round' (line 11)142 round_4 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 11, 10), 'round', False)143 # Calling round(args, kwargs) (line 11)144 round_call_result_9 = invoke(stypy.reporting.localization.Localization(__file__, 11, 10), round_4, *[Sample_call_result_7], **kwargs_8)145 146 # Declaration of the 'OtherSample' class147 class OtherSample:148 @norecursion149 def __float__(type_of_self, localization, *varargs, **kwargs):150 global module_type_store151 # Assign values to the parameters with defaults152 defaults = []153 # Create a new context for function '__float__'154 module_type_store = module_type_store.open_function_context('__float__', 15, 8, False)155 # Assigning a type to the variable 'self' (line 16)156 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 8), 'self', type_of_self)157 158 # Passed parameters checking function159 OtherSample.__float__.__dict__.__setitem__('stypy_localization', localization)160 OtherSample.__float__.__dict__.__setitem__('stypy_type_of_self', type_of_self)161 OtherSample.__float__.__dict__.__setitem__('stypy_type_store', module_type_store)162 OtherSample.__float__.__dict__.__setitem__('stypy_function_name', 'OtherSample.__float__')163 OtherSample.__float__.__dict__.__setitem__('stypy_param_names_list', ['other'])164 OtherSample.__float__.__dict__.__setitem__('stypy_varargs_param_name', None)165 OtherSample.__float__.__dict__.__setitem__('stypy_kwargs_param_name', None)166 OtherSample.__float__.__dict__.__setitem__('stypy_call_defaults', defaults)167 OtherSample.__float__.__dict__.__setitem__('stypy_call_varargs', varargs)168 OtherSample.__float__.__dict__.__setitem__('stypy_call_kwargs', kwargs)169 OtherSample.__float__.__dict__.__setitem__('stypy_declared_arg_number', 2)170 arguments = process_argument_values(localization, type_of_self, module_type_store, 'OtherSample.__float__', ['other'], None, None, defaults, varargs, kwargs)171 if is_error_type(arguments):172 # Destroy the current context173 module_type_store = module_type_store.close_function_context()174 return arguments175 # Initialize method data176 init_call_information(module_type_store, '__float__', localization, ['other'], arguments)177 178 # Default return type storage variable (SSA)179 # Assigning a type to the variable 'stypy_return_type'180 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)181 182 183 # ################# Begin of '__float__(...)' code ##################184 float_10 = get_builtin_python_type_instance(stypy.reporting.localization.Localization(__file__, 16, 19), 'float')185 # Assigning a type to the variable 'stypy_return_type' (line 16)186 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 16, 12), 'stypy_return_type', float_10)187 188 # ################# End of '__float__(...)' code ##################189 # Teardown call information190 teardown_call_information(localization, arguments)191 192 # Storing the return type of function '__float__' in the type store193 # Getting the type of 'stypy_return_type' (line 15)194 stypy_return_type_11 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 15, 8), 'stypy_return_type')195 module_type_store.store_return_type_of_current_context(stypy_return_type_11)196 197 # Destroy the current context198 module_type_store = module_type_store.close_function_context()199 200 # Return type of the function '__float__'201 return stypy_return_type_11202 @norecursion...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!