Package: red_utils
red-utils⚠️Important⚠️: This is my first Python package. I'm experimenting with CI/CD and Pypi. This library is most likely not useful to anyone else, may be broken at times, may undergo refactors with little to no notice/documentation, and all that other awful stuff that comes with being an amateur developer doing this in their free time 🙃Table of Contentsred-utilsTable of ContentsDescriptionDynamic importsInstallationDependency groups:Dependency install group examplesModulesDeveloping red-utilsDescription🔗Project Home - Github Repository🐍Red Utils on Pypi📖Red Utils DocsA collection of utility scripts/functions that I use frequently. Includes helper functions/default variables for libraries likeloguru,diskcache, andmsgpack.The utilities are broken down into 2 modules:std: Utilities with no external dependencies, only the Pythonstdlib.ext: Utilities for dependencies likeloguruandmsgpackNote: It is generally a good practice to importextmodules as a whole, instead of importing functions/variables from the module.This is because some of the function names I chose may be common (likeget_ts()in theext.time_utilsmodule).Example:from red_utils.ext import time_utils

now = time_utils.get_ts()or, withpendulum:from red_utils.ext.time_utils import pendulum_utils

now = pendulum_utils.get_ts()Common code shared by thestdandextmodules can be imported fromred_utils.coreandred_utils.domain. Any code in these modules should be clean of any external dependency. This is because thestdmodule imports fromcore, and adding non-stdlib functionality inred_utils.corebreaks the philosophy of thestdlibmodule. I may introduce ared_utils.ext.coreat some point.Some domain objects (dataclassor regular Python classes) may be stored inred_utils.domain. As of releasev0.2.12, this module is empty, but future releases may bring some utilities in the form of a class.Custom/common exceptions are stored inred_utils.exc.Dynamic importsThered-utilspackage makes use of the Python stdlibpkgutilmodule to control imports. Packages in theextmodule are only imported and available inred_utilsif the corresponding dependency exists.For instance,red_utils.ext.msgpack_utilswill only be available if this check insrc/red_utils/ext/init.pypasses:import pkgutil

...

if pkgutil.find_loader("msgpack"):
  from . import msgpack_utilspkgutil.find_loader()is used throughout the app to control imports and ensurered_utilsis stable, by keeping uninstalled module's utilities out of the namespace.InstallationThis project uses dependencies groups, meaning it can be installed withpip install red-utilsfor the base package, or with dependency groups likepip install red-utils[all](to install all packages with a corresponding red-util module),pip install red-utils[http](to install some helpful packages for HTTP requests, i.e.httpxanddiskcache), and more.pippip install red-utilspdmpdm add red-utilsDependency groups:Note: I will do my best to update this, but to get an accurate view of available dependency groups and the packages that will be installed, check thepyproject.tomlfile. Look for the dependency lists, i.e.dependencies = [(the base set of dependencies),all = [,http = [, etc.[all]: Install all packages that have a corresponding util. This may be a large install, and is generally not recommended.[arrow]: By default, thependulumlibrary is used fortime_utils. Installingred_utils[arrow]allows for importingarrowfunctions fromred_utils.ext.time_utils.arrow.[fastapi]: Dependencies forfastapi_utils[http]: My standard "HTTP toolkit." Comes with a request client (httpx), logging (loguru), caching (diskcache), & more.Dependency install group examplespip:pip install red-utils[fastapi,http]pdm:pdm add red-utils[fastapi,http]ModulesCheck theGithub pageto see modules in theextandstdmodules (or click one of those words to be taken there).Developing red-utilsPlease see thedeveloping docsfor instructions on setting up a dev environment to work onred-utils.