Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

flasklet

A few nice things for Flask: typed flash messages, convention-based blueprint auto-discovery, route auto-importing, and helpers for rendering partials, blocks, and macros from Python.

Typed configuration

flasklet.config gives Flask apps a typed, environment-backed settings object instead of untyped app.config dict lookups.

from flasklet import config


class Settings(config.Config, prefix="BOXMINDER_"):
	base_url: str = config.from_env(default="/")
	flush_interval_seconds: int = config.from_env(default=60)


def create_app() -> Flask:
	app = Flask(__name__)
	settings = config.load(Settings)
	config.init_app(app, settings, flask_keys={"APPLICATION_ROOT": "base_url"})
	return app

A field's variable name defaults to the field name uppercased, prefixed with the class-level prefix (here BOXMINDER_BASE_URL and BOXMINDER_FLUSH_INTERVAL_SECONDS). Pass a name to from_env to override it. The prefix is inherited by subclasses. load(Settings, prefix=...) prepends a further prefix at load time.

load reads the environment when called (inside the app factory, not at import time) and converts values to the field's declared type: str, int, float, bool, Path, Optional[T], list[T], and NewType wrappers. A bool accepts only the exact strings true and false; a list is split on commas, with an empty variable meaning the empty list. A required field with a missing variable, or a value that cannot be converted, raises with the offending variable named.

Settings derived from other settings are declared with derived. They are computed once when the object is built, in declaration order, so a derived field may read earlier ones. They are not constructor arguments.

class Settings(config.Config, prefix="BOXMINDER_"):
	data_dir: Path | None = config.from_env(default=None)
	base_dir: Path = config.derived(lambda s: (s.data_dir or PROJECT_ROOT).resolve())
	db_uri: str = config.derived(lambda s: f"sqlite:///{s.base_dir / 'db.sqlite3'}")

Request-time access is typed through the generic read_config, passing the settings class:

config.read_config(Settings).base_url

Metadata

Release files for flasklet 1.3.0b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flasklet 1.3.0b0
File Size Uploaded
flasklet-1.3.0b0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flasklet 1.3.0b0
File Interpreter ABI Platform
flasklet-1.3.0b0-py3-none-any.whl Python 3 none any Details

Total release size: 25.6 kB

Release files / flasklet-1.3.0b0.tar.gz

Download URL flasklet-1.3.0b0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2c71f8388d9de45bcd8a71abb3ec7f87cf415a16175667106369cf9c7687f26c
BLAKE2b-256 checksum
How to use checksums
7befafc6d49bb78edde71ef5940c91050fa5f0a9ae593bf7357e2ee7e9335911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / flasklet-1.3.0b0-py3-none-any.whl

Download URL flasklet-1.3.0b0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
950bbd00679564607aa89d49ae6e4d40e3e81b59c5fdc86d561a63a8c42534c1
BLAKE2b-256 checksum
How to use checksums
c58b51ebd6cad8d548396c85b394584b3162ee0a91cf0cb1322e7799832ff792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

3.0.1

2 release files

3.0.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.0

2 release files

This release

1.3.0b0 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.0.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page