How to use deprecated_func method in Slash

Best Python code snippet using slash

class_assignments_method_calls.py

Source:class_assignments_method_calls.py Github

copy

Full Screen

...74: 85: assertEquals = assertEqual96: 107: def _deprecate(original_func):118: def deprecated_func(*args, **kwargs):129: return original_func(*args, **kwargs)1310: 1411: return deprecated_func1512: 1613: failUnlessEqual = _deprecate(assertEqual)1714: 1815: 1916: t = TestCase()2017: 2118: r = t.assertEquals2219: 2320: r2 = t.failUnlessEqual2421: 2522: print r2623: print r22724: 28"""29# Import the stypy library necessary elements30from stypy.type_inference_programs.type_inference_programs_imports import *31# Create the module type store32module_type_store = Context(None, __file__)33# ################# Begin of the type inference program ##################34# Declaration of the 'TestCase' class35class TestCase(object, ):36 @norecursion37 def assertEqual(type_of_self, localization, *varargs, **kwargs):38 global module_type_store39 # Assign values to the parameters with defaults40 defaults = []41 # Create a new context for function 'assertEqual'42 module_type_store = module_type_store.open_function_context('assertEqual', 2, 4, False)43 # Assigning a type to the variable 'self' (line 3)44 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 3, 4), 'self', type_of_self)45 46 # Passed parameters checking function47 TestCase.assertEqual.__dict__.__setitem__('stypy_localization', localization)48 TestCase.assertEqual.__dict__.__setitem__('stypy_type_of_self', type_of_self)49 TestCase.assertEqual.__dict__.__setitem__('stypy_type_store', module_type_store)50 TestCase.assertEqual.__dict__.__setitem__('stypy_function_name', 'TestCase.assertEqual')51 TestCase.assertEqual.__dict__.__setitem__('stypy_param_names_list', [])52 TestCase.assertEqual.__dict__.__setitem__('stypy_varargs_param_name', None)53 TestCase.assertEqual.__dict__.__setitem__('stypy_kwargs_param_name', None)54 TestCase.assertEqual.__dict__.__setitem__('stypy_call_defaults', defaults)55 TestCase.assertEqual.__dict__.__setitem__('stypy_call_varargs', varargs)56 TestCase.assertEqual.__dict__.__setitem__('stypy_call_kwargs', kwargs)57 TestCase.assertEqual.__dict__.__setitem__('stypy_declared_arg_number', 1)58 arguments = process_argument_values(localization, type_of_self, module_type_store, 'TestCase.assertEqual', [], None, None, defaults, varargs, kwargs)59 if is_error_type(arguments):60 # Destroy the current context61 module_type_store = module_type_store.close_function_context()62 return arguments63 # Initialize method data64 init_call_information(module_type_store, 'assertEqual', localization, [], arguments)65 66 # Default return type storage variable (SSA)67 # Assigning a type to the variable 'stypy_return_type'68 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)69 70 71 # ################# Begin of 'assertEqual(...)' code ##################72 # Getting the type of 'None' (line 3)73 None_1088 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 3, 15), 'None')74 # Assigning a type to the variable 'stypy_return_type' (line 3)75 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 3, 8), 'stypy_return_type', None_1088)76 77 # ################# End of 'assertEqual(...)' code ##################78 # Teardown call information79 teardown_call_information(localization, arguments)80 81 # Storing the return type of function 'assertEqual' in the type store82 # Getting the type of 'stypy_return_type' (line 2)83 stypy_return_type_1089 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 2, 4), 'stypy_return_type')84 module_type_store.store_return_type_of_current_context(stypy_return_type_1089)85 86 # Destroy the current context87 module_type_store = module_type_store.close_function_context()88 89 # Return type of the function 'assertEqual'90 return stypy_return_type_108991 @staticmethod92 @norecursion93 def _deprecate(localization, *varargs, **kwargs):94 global module_type_store95 # Assign values to the parameters with defaults96 defaults = []97 # Create a new context for function '_deprecate'98 module_type_store = module_type_store.open_function_context('_deprecate', 7, 4, False)99 100 # Passed parameters checking function101 TestCase._deprecate.__dict__.__setitem__('stypy_localization', localization)102 TestCase._deprecate.__dict__.__setitem__('stypy_type_of_self', None)103 TestCase._deprecate.__dict__.__setitem__('stypy_type_store', module_type_store)104 TestCase._deprecate.__dict__.__setitem__('stypy_function_name', '_deprecate')105 TestCase._deprecate.__dict__.__setitem__('stypy_param_names_list', ['original_func'])106 TestCase._deprecate.__dict__.__setitem__('stypy_varargs_param_name', None)107 TestCase._deprecate.__dict__.__setitem__('stypy_kwargs_param_name', None)108 TestCase._deprecate.__dict__.__setitem__('stypy_call_defaults', defaults)109 TestCase._deprecate.__dict__.__setitem__('stypy_call_varargs', varargs)110 TestCase._deprecate.__dict__.__setitem__('stypy_call_kwargs', kwargs)111 TestCase._deprecate.__dict__.__setitem__('stypy_declared_arg_number', 1)112 arguments = process_argument_values(localization, None, module_type_store, '_deprecate', ['original_func'], None, None, defaults, varargs, kwargs)113 if is_error_type(arguments):114 # Destroy the current context115 module_type_store = module_type_store.close_function_context()116 return arguments117 # Initialize method data118 init_call_information(module_type_store, '_deprecate', localization, [], arguments)119 120 # Default return type storage variable (SSA)121 # Assigning a type to the variable 'stypy_return_type'122 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)123 124 125 # ################# Begin of '_deprecate(...)' code ##################126 @norecursion127 def deprecated_func(localization, *varargs, **kwargs):128 global module_type_store129 # Assign values to the parameters with defaults130 defaults = []131 # Create a new context for function 'deprecated_func'132 module_type_store = module_type_store.open_function_context('deprecated_func', 8, 8, False)133 134 # Passed parameters checking function135 deprecated_func.stypy_localization = localization136 deprecated_func.stypy_type_of_self = None137 deprecated_func.stypy_type_store = module_type_store138 deprecated_func.stypy_function_name = 'deprecated_func'139 deprecated_func.stypy_param_names_list = []140 deprecated_func.stypy_varargs_param_name = 'args'141 deprecated_func.stypy_kwargs_param_name = 'kwargs'142 deprecated_func.stypy_call_defaults = defaults143 deprecated_func.stypy_call_varargs = varargs144 deprecated_func.stypy_call_kwargs = kwargs145 arguments = process_argument_values(localization, None, module_type_store, 'deprecated_func', [], 'args', 'kwargs', defaults, varargs, kwargs)146 if is_error_type(arguments):147 # Destroy the current context148 module_type_store = module_type_store.close_function_context()149 return arguments150 # Initialize method data151 init_call_information(module_type_store, 'deprecated_func', localization, [], arguments)152 153 # Default return type storage variable (SSA)154 # Assigning a type to the variable 'stypy_return_type'155 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 0, 0), 'stypy_return_type', None)156 157 158 # ################# Begin of 'deprecated_func(...)' code ##################159 160 # Call to original_func(...): (line 9)161 # Getting the type of 'args' (line 9)162 args_1091 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 9, 34), 'args', False)163 # Processing the call keyword arguments (line 9)164 # Getting the type of 'kwargs' (line 9)165 kwargs_1092 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 9, 42), 'kwargs', False)166 kwargs_1093 = {'kwargs_1092': kwargs_1092}167 # Getting the type of 'original_func' (line 9)168 original_func_1090 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 9, 19), 'original_func', False)169 # Calling original_func(args, kwargs) (line 9)170 original_func_call_result_1094 = invoke(stypy.reporting.localization.Localization(__file__, 9, 19), original_func_1090, *[args_1091], **kwargs_1093)171 172 # Assigning a type to the variable 'stypy_return_type' (line 9)173 module_type_store.set_type_of(stypy.reporting.localization.Localization(__file__, 9, 12), 'stypy_return_type', original_func_call_result_1094)174 175 # ################# End of 'deprecated_func(...)' code ##################176 # Teardown call information177 teardown_call_information(localization, arguments)178 179 # Storing the return type of function 'deprecated_func' in the type store180 # Getting the type of 'stypy_return_type' (line 8)181 stypy_return_type_1095 = module_type_store.get_type_of(stypy.reporting.localization.Localization(__file__, 8, 8), 'stypy_return_type')182 module_type_store.store_return_type_of_current_context(stypy_return_type_1095)183 184 # Destroy the current context185 module_type_store = module_type_store.close_function_context()186 187 # Return type of the function 'deprecated_func'188 return stypy_return_type_1095189 # Assigning a type to the variable 'deprecated_func' (line 8)...

Full Screen

Full Screen

file_io.py

Source:file_io.py Github

copy

Full Screen

...86set_megfile()87# PathManager will be deprecated in the future.88class PathManager:89 @staticmethod90 @deprecated_func("use megfile.smart_open instead")91 def open(path: str, mode: str = "r"):92 """93 Open a stream to a URI, similar to the built-in `open`.94 Args:95 path (str): A URI supported by this PathHandler96 Returns:97 file: a file-like object.98 """99 return megfile.smart_open(path, mode)100 @staticmethod101 @deprecated_func("use megfile.smart_copy instead")102 def copy(src_path: str, dst_path: str) -> bool:103 """104 Copies a source path to a destination path.105 Args:106 src_path (str): A URI supported by this PathHandler107 dst_path (str): A URI supported by this PathHandler108 overwrite (bool): Bool flag for forcing overwrite of existing file109 Returns:110 status (bool): True on success111 """112 return megfile.smart_copy(src_path, dst_path)113 @staticmethod114 @deprecated_func("use megfile.smart_realpath instead")115 def get_local_path(path: str) -> str:116 """117 Get a filepath which is compatible with native Python I/O such as `open`118 and `os.path`.119 If URI points to a remote resource, this function may download and cache120 the resource to local disk.121 Args:122 path (str): A URI supported by this PathHandler123 Returns:124 local_path (str): a file path which exists on the local file system125 """126 return megfile.smart_realpath(path)127 @staticmethod128 @deprecated_func("use megfile.smart_exists instead")129 def exists(path: str) -> bool:130 """131 Checks if there is a resource at the given URI.132 Args:133 path (str): A URI supported by this PathHandler134 Returns:135 bool: true if the path exists136 """137 return megfile.smart_exists(path)138 @staticmethod139 @deprecated_func("use megfile.smart_isfile instead")140 def isfile(path: str) -> bool:141 """142 Checks if there the resource at the given URI is a file.143 Args:144 path (str): A URI supported by this PathHandler145 Returns:146 bool: true if the path is a file147 """148 return megfile.smart_isfile(path)149 @staticmethod150 @deprecated_func("use megfile.smart_isdir instead")151 def isdir(path: str) -> bool:152 """153 Checks if the resource at the given URI is a directory.154 Args:155 path (str): A URI supported by this PathHandler156 Returns:157 bool: true if the path is a directory158 """159 return megfile.smart_isdir(path)160 @staticmethod161 @deprecated_func("use megfile.smart_listdir instead")162 def ls(path: str):163 """164 List the contents of the directory at the provided URI.165 Args:166 path (str): A URI supported by this PathHandler167 Returns:168 List[str]: list of contents in given path169 """170 return megfile.smart_listdir(path)171 @staticmethod172 @deprecated_func("use megfile.smart_makedirs instead")173 def mkdirs(path: str, exist_ok: bool = True) -> None:174 """175 Recursive directory creation function. Like mkdir(), but makes all176 intermediate-level directories needed to contain the leaf directory.177 Similar to the native `os.makedirs`.178 Args:179 path (str): A URI supported by this PathHandler180 exist_ok (str): An exception will be raised if dir exist and exist_ok is Flase.181 """182 return megfile.smart_makedirs(path, exist_ok=exist_ok)183 @staticmethod184 @deprecated_func("use megfile.smart_remove instead")185 def rm(path: str) -> None:186 """187 Remove the file (not directory) at the provided URI.188 Args:189 path (str): A URI supported by this PathHandler190 """191 return megfile.smart_remove(path)192 @staticmethod193 @deprecated_func("use megfile.smart_stat instead")194 def stat(path: str):195 """196 get status of the file at the provided URI.197 Args:198 path (str): A URI supported by this PathHandler199 """200 return megfile.smart_stat(path)201 @staticmethod202 @deprecated_func("use megfile.s3_upload instead")203 def upload(local: str, remote: str):204 """205 Upload the local file (not directory) to the specified remote URI.206 Args:207 local (str): path of the local file to be uploaded.208 remote (str): the remote s3uri.209 """210 try:211 megfile.s3_upload(local, remote)212 except Exception:213 return False214 return True215 @staticmethod216 @deprecated_func("use megfile.smart_path_join instead")217 def join(*paths):...

Full Screen

Full Screen

test_utils.py

Source:test_utils.py Github

copy

Full Screen

...41 assert test_handler.records[0].message == 'checking...'42 with pytest.raises(TypeError):43 logged_if_slow('checking...', logger=logger, func=logger.error)44def test_deprecated_func_called(capture):45 assert deprecated_func(1, 2) == 346def test_deprecation_message(capture):47 deprecated_func(1, 2)48 [record] = capture.records49 assert "deprecated" in record.message50 assert 'deprecated_func' in record.message51def test_deprecation_with_message(capture):52 @deprecated("use something else instead")53 def func(a, b):54 return a + b55 func(1, 2)56 [record] = capture.records57 assert "use something else instead" in record.message58 assert "func is deprecated" in record.message59def test_no_deprecations(capture):60 @deprecated('msg')61 def func(a, b):62 return a + b63 with suppressed_deprecations():64 assert func(1, 2) == 365 assert not capture.records66def _no_decorator(func):67 return func68@pytest.mark.parametrize('decorator', [_no_decorator, classmethod])69def test_class_deprecation(capture, decorator):70 class Bla(object):71 @deprecated('reason')72 @classmethod73 def func(self, a, b):74 assert isinstance(self, Bla)75 return a + b76 assert Bla().func(2, 4) == 677 [record] = capture.records78 assert 'Bla.func is deprecated' in record.message79def test_deprecations_different_sources(capture):80 def f():81 deprecated_func(1, 2)82 def g():83 deprecated_func(1, 2)84 f()85 g()86 assert len(capture.records) == 287def test_deprecations_same_sources(capture):88 def f():89 deprecated_func(1, 2)90 f()91 f()92 assert len(capture.records) == 193def test_deprecation_message_different_sources(capture):94 def f(flag):95 if flag:96 log_deprecation_message('first message type')97 else:98 log_deprecation_message('second message type')99 f(True)100 f(False)101 assert len(capture.records) == 2102def test_deprecation_message_same_sources(capture):103 def f(flag):104 if flag:105 log_deprecation_message('first message type')106 else:107 log_deprecation_message('second message type')108 f(True)109 f(True)110 assert len(capture.records) == 1111def test_deprecation_message_full_warning(capture):112 def f():113 log_deprecation_message('some_message')114 f()115 [record] = capture.records116 assert record.message == 'Deprecation message: some_message'117def test_name_doc():118 @deprecated119 def some_func():120 """docstring here"""121 pass122 assert some_func.__name__ == 'some_func'123 assert 'docstring here' in some_func.__doc__124def test_doc_update():125 @deprecated('some_message')126 def some_func():127 """docstring here"""128 pass129 some_func.__doc__ = 'new_docstring'130 assert 'docstring here' not in some_func.__doc__131 assert 'new_docstring' in some_func.__doc__132 assert 'some_message' in some_func.__doc__133def test_deprecatd_docstring():134 message = "Use something else instead"135 @deprecated()136 def some_func():137 """This is a function138 """139 @deprecated(message)140 def other_func():141 """This is another function142 """143 assert ".. deprecated" in some_func.__doc__144 assert ".. deprecated\n {0}".format(message) in other_func.__doc__145@pytest.fixture146def capture(request):147 handler = logbook.TestHandler(level=logbook.WARNING)148 handler.push_application()149 @request.addfinalizer150 def pop():151 handler.pop_application()152 return handler153@deprecated154def deprecated_func(a, b):155 return a + b156@pytest.fixture(autouse=True)157def forget_locations():...

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 Slash 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