Package: miller
What is miller?"I'm a tool that finds things."- Detective Josephus MillerNamed after the erstwhile inspector fromThe Expanse, this package provides convenient, introspection tools using a consistent, intuitive syntax for packages, modules, classes, objects, attributes, and containers.Why miller?UniversalConsider the different and often difficult-to-read syntax that Python uses for introspection of different objects."""Returns a list of function names in the module 'item'."""[m[0]formininspect.getmembers(item,inspect.isfunction)ifm[1].__module__==item.__name__]"""Returns names of properties of the instance 'item'."""[aforaindir(item)ifisinstance(getattr(a,item),property)]"""Returns names of fields of the dataclass 'item'."""[f.nameforfindataclasses.fields(item)]That code can be difficult to remember, requires importing a range of packages, and is not easy to understand if you are not familiar with the relevant imported packages.In contrast,milleruses simple, easy-to-read code for each of the above requests:name_functions(item)name_properties(item)name_fields(item)In addition, each of thosemillerfunctions includes a boolean parameterinclude_privateswhich indicates whether you want to include any matching items that have str names beginning with an underscore.IntuitiveUnlike the default Python instrospection functions and methods,milleruses a consistent syntax and structure that is far more intuitive. This allows users to guess what the appropriate syntax should by following a simple, consistent structure.milleruses five basic prefixes for its introspection functions:prefixwhat it doesreturnsmapcombines results of correspondingnameandgetfunctions into adictdict[str, Any]getgets sought types from an itemlist[Any]haswhether an item has specified typesbooliswhether an item is a typeboolnamegetsstrnames of sought types from an itemlist[str]Those prefixes are followed by an underscore and a suffix indicating what information is sought.millerhas XXX possible suffixes for each of those prefixes:suffixwhat it concernswhat types it inspectsannotationsclass, function, or method annotationsobject,Type, orModuleTypeattributean attribute (including methods) of a classattribute in anobjectorTypeattributesattributes (including methods or functions)object,Type, orModuleTypeclassa class (not an instance)objectorTypeclassesclasses in a moduleModuleTypeclass_attributeattributes of a class (not an instance)objectorTypeclass_attributesattributes of a class (not an instance)objectorTypefieldfield in a dataclassdataclassorType[dataclass]fieldsfields in a dataclassdataclassorType[dataclass]file_pathpath of a filestrorPathfile_pathspaths of files in a pathstrorPathfolder_pathpath of a folderstrorPathfolder_pathspaths of folders in a pathstrorPathfunctiona callable functionobjectfunctionsfunctions in a moduleModuleTypeinstancea class instance (not a class)objectorTypemethodmethod in a classattribute in anobjectorTypemethodsclass or instance methodsobjectorTypemodulemodule typesobjectorTypemodulespaths of modules in a pathstrorPathpathpath on diskstrorPathpathscombination of file_paths and folder_pathsstrorPathpropertyattributes of a classattribute in anobjectpropertiesproperties of a classobjectorTypesignaturesclass, function, or method signaturesobject,Type, orModuleTypevariableattributes (excluding methods) of a classobject,Type, orModuleTypevariablesan attribute (excluding methods or functions)object,Type, orModuleTypeThe following functions are available inmillerfor themap,get,has, andnamesuffixes :| prefix/suffix |map|get|has|name|
|---|---|---|---|---|---|---|
|annotations| X | X | X | X |
|attributes| X | X | X | X |
|classes| X | X | X | X |
|fields| X | X | X | X |
|file_paths| X | X | X | X |
|folder_paths| X | X | X | X |
|functions| X | X | X | X |
|methods| X | X | X | X |
|modules| X | X | X | X ||paths| X | X | X | X |
|properties| X | X | X | X |
|signatures| X | X | X | X |
|variables| X | X | X | X |For theisprefix, functions with the following suffixes are included:So, for example,map_methods: returns a dict of the method names and methods of an object.get_methods: returns a list of methods of an object.has_methods: returns whether an object has all of the named methods passed to themethodsparameter.is_method: returns whether an item is a method of an object.name_methods: returns a list of names of methods of an object.ContributingThe project is highly documented so that users and developers can makemillerwork with their projects. It is designed for Python coders at all levels. Beginners should be able to follow the readable code and internal documentation to understand how it works. More advanced users should find complex and tricky problems addressed through efficient code.