Package: py-check
py-checkA general-purpose check library for python.This is a python implementation of part ofis.js.Installationpipinstallpy-checkUsagefrompycheckimportcheckcheck.integer(...)check.any.integer(...)check.all.integer(...)Type Checkscheck.integer(value: Any)Checks if the given value(s) type is integerinterface: all, anycheck.integer(123)=>Truecheck.integer(True)=>Falsecheck.all.integer(1,'a')=>Falsecheck.any.integer(1,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.integer([1,2,3])=>Truecheck.float(value: Any)Checks if the given value(s) type is floatinterface: all, anycheck.float(0.2)=>Truecheck.all.float(0.2,math.inf)=>Truecheck.any.float(0.2,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.float([1.1,1.2,2])=>Falsecheck.boolean(value: Any)Checks if the given value(s) type is booleaninterface: all, anycheck.boolean(1)=>Falsecheck.all.boolean(True,1)=>Falsecheck.any.boolean(False,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.boolean([True,False])=>Truecheck.string(value: Any)Checks if the given value(s) type is stringinterface: all, anycheck.string('')=>Truecheck.all.string(True,'a')=>Falsecheck.any.string(False,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.string(['True','1'])=>Truecheck.char(value: Any)Checks if the given value(s) type is charinterface: all, anycheck.char('s')=>Truecheck.all.char(True,'a')=>Falsecheck.any.char(False,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.char(['s','1'])=>Truecheck.list(value: Any)Checks if the given value(s) type is listinterface: all, anycheck.list([1,'a'])=>Truecheck.all.list(1,[1,'a'])=>Falsecheck.all.list([1,2,3])=>Falsecheck.any.list([],1)=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.list([1,[1,2,3]])=>Falsecheck.dictionary(value: Any)Checks if the given value(s) type is dictionaryinterface: all, anycheck.dictionary({})=>Truecheck.all.dictionary({'a':1},'a')=>Falsecheck.any.dictionary({'a':1},'a')# 'all' and 'any' interfaces can also take argument of list typecheck.all.dictionary([{'a':1},'a'])=>Falsecheck.set(value: Any)Checks if the given value(s) type is setinterface: all, anycheck.set(set({}))=>Truecheck.set({})=>Falsecheck.all.set({1,2,3},[1,2,3])=>Falsecheck.any.set({1,2,3},'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.set([{1,2,3},[1,2,3]])=>Falsecheck.tuple(value: Any)Checks if the given value(s) type is tupleinterface: all, anycheck.tuple((1,2))=>Truecheck.all.tuple({1,2},(1,2))=>Falsecheck.any.tuple((),'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.tuple([{1,2},(1,2)])=>Falsecheck.none(value: Any)Checks if the given value(s) type is Noneinterface: all, anycheck.none(None)=>Truecheck.all.none({1,2},None)=>Falsecheck.any.none(None,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.none([{1,2},None])=>Falsecheck.function(value: Any)Checks if the given value(s) type is functioninterface: all, anycheck.function(foo)=>Truecheck.all.function({1,2},foo)=>Falsecheck.any.function(foo,'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.function([{1,2},foo])=>Falsecheck.date(value: Any)Checks if the given value(s) type is dateinterface: all, anycheck.date(datetime.date(2020,7,1))=>Truecheck.all.date({1,2},datetime.date(2020,7,1))=>Falsecheck.any.date(datetime.date(2020,7,1),'a')=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.date([{1,2},datetime.date(2020,7,1)])=>Falsecheck.date_string(value: Any, string_pattern: str = '%Y-%m-%d')Checks if the given value(s) type is date by string patterninterface: all, anycheck.date('2020-7-1')=>Truecheck.date('2020/7/1',string_pattern='%Y/%m/%d')=>Truecheck.all.date('2020-7-1','2020-8-1')=>Truecheck.any.date('2020-7-1',1)=>True# 'all' and 'any' interfaces can also take argument of list typecheck.all.date(['2020-7-1','2020-8-1',1])=>Falsecheck.same_type(value: Any, *args: Any)Checks if the given values types are the sameinterface: no interfacecheck.same_type(1)=>Truecheck.same_type(1.1)=>Truecheck.same_type(True,1)=>Falsecheck.same_type(1,False)=>Falsecheck.same_type(1,2,3)=>TrueTodoType Checkscheck.datecheck.same_typePresence Checkscheck.emptycheck.truthycheck.falsyString Checkscheck.uppercasecheck.lowercasecheck.capitalizedInteger Checkscheck.evencheck.oddcheck.positivecheck.negative