PKsF-OyQQ pystrict.py# pylint: disable=protected-access """ ## strict Using @strict on classes can prevent serious errors by raising an exception when an instance has a variable created outside of init. """ __version__ = "1.1" import inspect, itertools, functools __all__ = ['strict', 'StrictError'] class StrictError(TypeError): pass def _check_args(func, *, checkret): info = inspect.getfullargspec(func) for k in itertools.chain(info.args, info.kwonlyargs): if k != "self" and k not in func.__annotations__: raise StrictError("%s argument %s is missing type specifier" % (func.__name__, k)) if checkret: if "return" not in func.__annotations__: raise StrictError("%s missing return type specifier" % func.__name__) def _init_decorator(func): @functools.wraps(func) def wrapper(self, *args, **kwargs): func(self, *args, **kwargs) self._x_frozen = True return wrapper def strict(thing): if inspect.isfunction(thing): func = thing _check_args(func, checkret=True) return func else: cls = thing def frozen_setattr(self, key, value): if self._x_frozen and not hasattr(self, key): raise StrictError("Class %s is frozen. Cannot set '%s'." % (cls.__name__, key)) cls._x_setter(self, key, value) cls._x_frozen = False cls._x_setter = getattr(cls, "__setattr__", object.__setattr__) cls.__setattr__ = frozen_setattr _check_args(cls.__init__, checkret=False) cls.__init__ = _init_decorator(cls.__init__) return cls PKJ,Ovw!!pystrict-1.1.dist-info/LICENSECopyright (c) 2019 Erik Aronesty Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK!HPOpystrict-1.1.dist-info/WHEEL HM K-*ϳR03rOK-J,/RH,szd&Y)r$[)T&UrPK!H,ŵ9pystrict-1.1.dist-info/METADATARMoFﯘJEIqc1⏠Ӄa8PܘYI,EuʃDμ\ J|%*ĥ4X"HsGNЕppC38r5 tԤE bnoxOW^D %~NHݖ{Tߓ';ư_g wdyf"Д?TnmVƨkyaVp*V!% [y'AxF\]/-4F%KLSo?Ν*]Mkp'9~A\*}q{m$)ŻnJlj"qc0x,!AH.~m$ٶW%M̦\<|y{w) BFamX7hsKld +K.ZPo%Bp5C5.PmCh5TB0b%d]Fjt,βNᆵ[I9 ^DB8ڮxf:Y`B0C#QAU_FlCWXko׳z#6ivt͖-dc>t#oYgkm< 8-kC0:>G kmJ B7(ش >3 *FӱqUåOSfp6w:9cgo_߰PK!HJfpystrict-1.1.dist-info/RECORDuMB@{e 8tL%a}\<[Ӄ{YGx[B+~Em-=TnYIˆKwޤɮy @7XB ieY͇ױCz9R|fW