fastcfg package

Subpackages

Submodules

fastcfg.exceptions module

exception fastcfg.exceptions.ConfigItemValidationError(message: str)[source]

Bases: Exception

Exception raised when a config item value fails validation.

exception fastcfg.exceptions.FileReadError[source]

Bases: Exception

Exception raised when a file cannot be read.

exception fastcfg.exceptions.InvalidOperationError(message: str = 'Invalid operation performed.')[source]

Bases: Exception

Exception raised when an invalid operation is performed.

exception fastcfg.exceptions.MaxRetriesExceededError(backoff_policy, total_time_slept: float)[source]

Bases: Exception

Exception raised when the maximum number of retries is exceeded in exponential backoff.

exception fastcfg.exceptions.MissingCacheKeyError(key)[source]

Bases: Exception

Exception raised when a cache key doesn’t exist.

exception fastcfg.exceptions.MissingConfigKeyError(key)[source]

Bases: Exception

Exception raised when a config key doesn’t exist.

exception fastcfg.exceptions.MissingDependencyError(dependency: str)[source]

Bases: Exception

Exception raised when a dependency is missing.

exception fastcfg.exceptions.MissingEnvironmentVariableError(key)[source]

Bases: Exception

Exception raised when an environment variable doesn’t exist.

exception fastcfg.exceptions.NetworkError[source]

Bases: Exception

Exception raised when a config key doesn’t exist.

Module contents

FastCFG - Modern configuration management for Python applications.

Created by Josh Breidinger (2025) Author: Josh Breidinger Email: company@breisoft.com GitHub: https://github.com/breisoft

Born from the frustration of serverless configuration hell, FastCFG makes config management simple, fast, and reliable.

fastcfg.needs_value(func: Callable[[...], Any], config_value: Any, *args: Any, verbose: bool = False, **kwargs: Any) bool | None[source]

Test whether a function requires explicit .value access or works with FastCFG magic.

This helper function determines if you can pass a FastCFG config value directly to a function, or if you need to use .value to extract the underlying value. This is particularly useful for identifying C extensions that require exact types.

Parameters:
  • func – The function to test compatibility with

  • config_value – A FastCFG wrapped value (e.g., config.port)

  • *args – Additional positional arguments to pass to func (after config_value)

  • verbose – If True, prints diagnostic information about the test

  • **kwargs – Keyword arguments to pass to func

Returns:

  • False: Function works with FastCFG magic (no .value needed)

  • True: Function requires .value to be called on config_value

  • None: Function doesn’t work even with .value (incompatible)

Return type:

bool or None

Example

config.size = 10

# Check if np.zeros needs .value if needs_value(np.zeros, config.size):

arr = np.zeros(config.size.value)

else:

arr = np.zeros(config.size)

# With verbose output for debugging needs_value(np.zeros, config.size, verbose=True) # Prints: zeros requires .value - use config.size.value

fastcfg.refresh(target: Config | AbstractConfigItem)[source]

Manually refresh a Config or ConfigItem to detect external changes.

Parameters:

target – Config object or ConfigItem to refresh

Example

# In your own loop for _ in range(60):

refresh(config.my_var) # Triggers change detection time.sleep(1)