How to use _get_qualified_name method in pandera

Best Python code snippet using pandera_python

removals.py

Source:removals.py Github

copy

Full Screen

...16from oslo_utils import reflection17import six18import wrapt19from debtcollector import _utils20def _get_qualified_name(obj):21 # Prefer the py3.x name (if we can get at it...)22 try:23 return (True, obj.__qualname__)24 except AttributeError:25 return (False, obj.__name__)26def _get_module_name(mod):27 return _get_qualified_name(mod)[1]28def remove(f=None, message=None, version=None, removal_version=None,29 stacklevel=3):30 """Decorates a function, method, or class to emit a deprecation warning31 :param str message: A message to include in the deprecation warning32 :param str version: Specify what version the removed function is present in33 :param str removal_version: What version the function will be removed. If34 '?' is used this implies an undefined future35 version36 :param int stacklevel: How many entries deep in the call stack before37 ignoring38 """39 if f is None:40 return functools.partial(remove, message=message,41 version=version,42 removal_version=removal_version,43 stacklevel=stacklevel)44 @wrapt.decorator45 def wrapper(f, instance, args, kwargs):46 qualified, f_name = _get_qualified_name(f)47 if qualified:48 if inspect.isclass(f):49 prefix_pre = "Using class"50 thing_post = ''51 else:52 prefix_pre = "Using function/method"53 thing_post = '()'54 if not qualified:55 prefix_pre = "Using function/method"56 base_name = None57 if instance is None:58 # Decorator was used on a class59 if inspect.isclass(f):60 prefix_pre = "Using class"61 thing_post = ''62 module_name = _get_module_name(inspect.getmodule(f))63 if module_name == '__main__':64 f_name = reflection.get_class_name(65 f, fully_qualified=False)66 else:67 f_name = reflection.get_class_name(68 f, fully_qualified=True)69 # Decorator was a used on a function70 else:71 thing_post = '()'72 module_name = _get_module_name(inspect.getmodule(f))73 if module_name != '__main__':74 f_name = reflection.get_callable_name(f)75 # Decorator was used on a classmethod or instancemethod76 else:77 thing_post = '()'78 base_name = reflection.get_class_name(instance,79 fully_qualified=False)80 if base_name:81 thing_name = ".".join([base_name, f_name])82 else:83 thing_name = f_name84 else:85 thing_name = f_name86 if thing_post:87 thing_name += thing_post88 prefix = prefix_pre + " '%s' is deprecated" % (thing_name)89 out_message = _utils.generate_message(90 prefix,91 version=version,92 removal_version=removal_version,93 message=message)94 _utils.deprecation(out_message, stacklevel)95 return f(*args, **kwargs)96 return wrapper(f)97def removed_kwarg(old_name, message=None,98 version=None, removal_version=None, stacklevel=3):99 """Decorates a kwarg accepting function to deprecate a removed kwarg."""100 prefix = "Using the '%s' argument is deprecated" % old_name101 out_message = _utils.generate_message(102 prefix, postfix=None, message=message, version=version,103 removal_version=removal_version)104 def decorator(f):105 @six.wraps(f)106 def wrapper(*args, **kwargs):107 if old_name in kwargs:108 _utils.deprecation(out_message, stacklevel=stacklevel)109 return f(*args, **kwargs)110 return wrapper111 return decorator112def removed_module(module, replacement=None, message=None,113 version=None, removal_version=None, stacklevel=3):114 """Helper to be called inside a module to emit a deprecation warning115 :param str replacment: A location (or information about) of any potential116 replacement for the removed module (if applicable)117 :param str message: A message to include in the deprecation warning118 :param str version: Specify what version the removed module is present in119 :param str removal_version: What version the module will be removed. If120 '?' is used this implies an undefined future121 version122 :param int stacklevel: How many entries deep in the call stack before123 ignoring124 """125 if inspect.ismodule(module):126 module_name = _get_module_name(module)127 elif isinstance(module, six.string_types):128 module_name = module129 else:130 _qual, type_name = _get_qualified_name(type(module))131 raise TypeError("Unexpected module type '%s' (expected string or"132 " module type only)" % type_name)133 prefix = "The '%s' module usage is deprecated" % module_name134 if replacement:135 postfix = ", please use %s instead" % replacement136 else:137 postfix = None138 out_message = _utils.generate_message(prefix,139 postfix=postfix, message=message,140 version=version,141 removal_version=removal_version)...

Full Screen

Full Screen

configure.py

Source:configure.py Github

copy

Full Screen

...25 DATABASE_URI = 'sqlite:///:memory:'26 SECRET_KEY = 'secret_key'27 SCSS_FILTERS = 'scss'28 COFFEESCRIPT_FILTERS = 'coffeescript'29def _get_qualified_name(config):30 return __name__ + '.' + config.__name__31# Load default values used in all environments.32app.config.from_object(_get_qualified_name(Configuration))33# Specify the configurations for all environments that are not production.34_CONFIGURATIONS = {35 'dev': DevelopmentConfiguration,36 'test': TestingConfiguration37}38environment = os.environ.get('MSG_ENVIRONMENT', 'prod')39if environment == 'prod':40 # Load the configuration defined in a separate file for the production environment.41 prod_config_path = os.environ.get('MSG_PROD_CONFIG', '../etc/matchstreamguide.cfg')42 app.config.from_pyfile(prod_config_path)43else:44 # Load the configuration for the environment that is not production.45 app.config.from_object(_get_qualified_name(_CONFIGURATIONS[environment]))46# Remove some whitespace from the HTML.47app.jinja_env.trim_blocks = app.config['JINJA_TRIM_BLOCKS']48# Compile Coffeescript with the top-level function safety wrapper.49env = Environment(app)50env.config['coffee_no_bare'] = app.config['COFFEE_NO_BARE']51# Compile Sass.52css = Bundle('style.scss', filters=app.config['SCSS_FILTERS'], output='gen/style.css')53env.register('all_css', css)54# Compile CoffeeScript.55app_js = Bundle('app.coffee', filters='coffeescript', output='gen/app.js')56settings_js = Bundle(57 'settings.coffee', filters=app.config['COFFEESCRIPT_FILTERS'], output='gen/settings.js')58env.register('app_js', app_js)59env.register('settings_js', settings_js)...

Full Screen

Full Screen

deprecation.py

Source:deprecation.py Github

copy

Full Screen

...17 if date is not None and not re.match(r'20\d\d-[01]\d-[0123]\d', date):18 raise ValueError('Date must be YYYY-MM-DD.')19 if not instructions:20 raise ValueError('Don\'t deprecate things without conversion instructions!')21def _get_qualified_name(function):22 # Python 323 if hasattr(function, '__qualname__'):24 return function.__qualname__25 # Python 226 if hasattr(function, 'im_class'):27 return function.im_class.__name__ + '.' + function.__name__28 return function.__name__29def deprecated(date, instructions):30 _validate_deprecation_args(date, instructions)31 def deprecated_wrapper(func):32 _validate_callable(func, 'deprecated')33 @functools.wraps(func)34 def new_func(*args, **kwargs):35 from dragon.config import logger36 if _PRINT_DEPRECATION_WARNINGS:37 logger.warning(38 '{} (from {}) is deprecated and will be removed {}.\n'39 'Instructions for updating:\n{}'.40 format(_get_qualified_name(func),41 func.__module__,42 'in a future version' if date is None else ('after %s' % date),43 instructions))44 return func(*args, **kwargs)45 return new_func...

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