How to use compat_kwargs method in pandera

Best Python code snippet using pandera_python

compat.py

Source: compat.py Github

copy

Full Screen

...149 def _testfunc(x):150 pass151 _testfunc(**{'x': 0})152except TypeError:153 def compat_kwargs(kwargs):154 return dict((bytes(k), v) for k, v in kwargs.items())155else:156 compat_kwargs = lambda kwargs: kwargs157if sys.version_info < (3, 0) and sys.platform == 'win32':158 def compat_getpass(promt, *args, **kwargs):159 if isinstance(promt, compat_str):160 from .utils import preferredencoding161 promt = promt.encode(preferredencoding())162 return getpass.getpass(promt, *args, **kwargs)163else:164 compat_getpass = getpass.getpass165__all__ = [166 'compat_shlex_split', # 分解命令行的参数167 'compat_getenv', # 获取指定key的环境变量...

Full Screen

Full Screen

init_subclass.py

Source: init_subclass.py Github

copy

Full Screen

1"""2Backport of the functionality of `__init_subclass__` from3`PEP 487 <https:/​/​peps.python.org/​pep-0487/​>`_ to Python 2.7.4"""5import sys6import six7from .get_mro import get_mro8__all__ = ["InitSubclassMeta", "InitSubclass"]9class InitSubclassMeta(type):10 """Metaclass that backports the functionality of `__init_subclass__` from PEP 487 to Python 2.7."""11 @staticmethod12 def __new__(mcs, name, bases, dct, **kwargs):13 # Keep a copy of the original kwargs -- they are sometimes used by generics.14 original_kwargs = dict(kwargs)15 # Wipe out kwargs if using older python.16 if sys.version_info[:3] < (3, 6):17 kwargs = dict()18 # Get compatibility kwargs (defined in the body of the class).19 dct_had_kwargs = "__kwargs__" in dct20 if dct_had_kwargs:21 compat_kwargs = dct["__kwargs__"]22 else:23 compat_kwargs = {}24 # Error out if the same kwarg is defined both in the body and in the class arguments.25 conflicting_kwargs = set(compat_kwargs).intersection(kwargs)26 if conflicting_kwargs:27 error = "conflicting class keyword arguments {}".format(28 ", ".join(sorted(repr(k) for k in conflicting_kwargs))29 )30 raise TypeError(error)31 # Merge kwargs.32 kwargs.update(compat_kwargs)33 # For older python versions.34 if sys.version_info[:3] < (3, 6):35 # Ensure classmethod.36 if "__init_subclass__" in dct and not isinstance(dct["__init_subclass__"], classmethod):37 dct = dict(dct)38 dct["__init_subclass__"] = classmethod(dct["__init_subclass__"])39 # Build class and pass original kwargs (for generics).40 cls = super(InitSubclassMeta, mcs).__new__(mcs, name, bases, dct, **original_kwargs)41 # Find '__init_subclass__' method.42 method = None43 method_owner = None44 for base in get_mro(cls):45 if base is cls:46 continue47 method = base.__dict__.get("__init_subclass__")48 if method is not None:49 method_owner = base50 break51 # Found a method.52 if method is not None:53 # Invalid base.54 if not isinstance(method_owner, InitSubclassMeta):55 error = "base {!r} defines '__init_subclass__' but does not utilize {!r} as a metaclass".format(56 method_owner.__name__, InitSubclassMeta.__name__57 )58 raise TypeError(error)59 # Call it with compat kwargs only.60 method.__func__(cls, **compat_kwargs)61 # Have kwargs but no method was found.62 elif kwargs:63 error = "object.__init_subclass__() takes no keyword arguments"64 raise TypeError(error)65 # We don't need to do anything for newer python versions, just pass the merged kwargs.66 else:67 cls = super(InitSubclassMeta, mcs).__new__(mcs, name, bases, dct, **kwargs)68 # Remove kwargs from the body of the class.69 if not dct_had_kwargs and hasattr(cls, "__kwargs__"):70 error = "one or more bases for class {!r} define {!r} but do not utilize {!r} as a metaclass".format(71 name, "__kwargs__", InitSubclassMeta.__name__72 )73 raise TypeError(error)74 elif dct_had_kwargs:75 type.__delattr__(cls, "__kwargs__")76 return cls77class InitSubclass(six.with_metaclass(InitSubclassMeta, object)):78 """Class that backports the functionality of `__init_subclass__` from PEP 487 to Python 2.7"""79 __slots__ = ()80 if sys.version_info[:3] < (3, 6):81 def __init_subclass__(cls):...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

How To Write End-To-End Tests Using Cypress App Actions

When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.

Pair testing strategy in an Agile environment

Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Different Ways To Style CSS Box Shadow Effects

Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.

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