Skip to main content

ScoloConfig

ScoloConfig provides safe typed configuration for Python bots and services. It uses pydantic-settings for validation, reads process environment and optional .env files, masks secrets by default, and emits safe startup events through ScoloLogger.

Installation

pip install ScoloConfig

Quick start

from pydantic import SecretStr
from scoloconfig import ScoloSettings, SettingsConfig

class AppConfig(ScoloSettings):
    model_config = SettingsConfig(
        env_file='.env',
        env_prefix='BOT_',
    )

    token: SecretStr
    debug: bool = False
    request_timeout: float = 35.0

config = AppConfig.load()
config.log_startup()

bot_token = config.token.get_secret_value()

With this model, BOT_TOKEN, BOT_DEBUG, and BOT_REQUEST_TIMEOUT are read from the process environment. Values in the process environment always override .env.

.env

BOT_TOKEN=123456:replace-with-a-real-token-locally
BOT_DEBUG=false
BOT_REQUEST_TIMEOUT=35

Commit .env.example, not .env. Production deployments should inject settings through the process environment or a dedicated secret manager.

Secret safety

Use SecretStr or SecretBytes for credentials. ScoloConfig also masks fields whose names include token, secret, password, api_key, private_key, authorization, or cookie.

config.redacted_dump()
# {
#   'token': '***REDACTED***',
#   'debug': False,
#   'request_timeout': 35.0,
# }

Secrets are not included in repr, redacted_json(), source_report(), log_startup(), or safe validation errors. Reveal a secret only at the narrow point where a client requires it:

token = config.token.get_secret_value()

Explicit environment names

Use env() when a field should map to an exact environment variable instead of a prefix-derived name.

from pydantic import SecretStr
from scoloconfig import ScoloSettings, env

class LegacyConfig(ScoloSettings):
    telegram_token: SecretStr = env('TELEGRAM_BOT_TOKEN')
    retries: int = env('RETRIES', default=3)

Safe startup report

from scolologger import configure

configure(level='INFO', json_output=True)
report = config.log_startup()

The report includes only the settings class name, source categories, secret field names, and number of validated fields. It never includes configuration values.

Limits

ScoloConfig 0.1.0 supports process environment and .env files. It does not fetch remote secrets, watch files, mutate a running configuration object, or replace a dedicated secrets manager.

License

MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scoloconfig-0.1.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scoloconfig-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file scoloconfig-0.1.0.tar.gz.

File metadata

  • Download URL: scoloconfig-0.1.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for scoloconfig-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fba3ed8f01641a71ba024d2cbf6bef8c5a5c2b386f12c6fedb3062b1bebdd009
MD5 6fbd9a679d1defbbaacc8ff6adbe8d1c
BLAKE2b-256 ead58affdaf8e582c3e960fd0fdebdb40168ed4561334020a0f8544310c10108

See more details on using hashes here.

File details

Details for the file scoloconfig-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: scoloconfig-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for scoloconfig-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a357f58537ce4bd69bcf3b5cf8e7b2df0d82db9bd1db7d92778a3a6458dd1a82
MD5 7bae82265aa32a14f15759d2e30e4c5b
BLAKE2b-256 c61534cd69b888472fc46741d0b4022efd345119c7d4e0d59aaa8ec8fb890e0a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page