pydantic-settings-op
A 1Password secrets source for pydantic-settings.
Installation
pip install pydantic-settings-op
Usage
from pydantic_settings import BaseSettings
from pydantic_settings_op import OPVaultSettingsSource
class Settings(BaseSettings):
db_password: str
api_key: str
@classmethod
def settings_customise_sources(cls, settings_cls, init_settings, env_settings, dotenv_settings, file_secret_settings):
return (init_settings, env_settings, OPVaultSettingsSource(settings_cls, vault="MyVault"))
settings = Settings()
By convention, each field name is used as the 1Password item name within the configured vault, trying password then credential as the field name (configurable via default_fields).
Explicit field references with OPField
For fields that don't follow the convention, use OPField to specify an explicit secret reference:
from typing import Annotated
from pydantic_settings_op import OPField
class Settings(BaseSettings):
# Relative path — vault from OPVaultSettingsSource is prepended
db_password: Annotated[str, OPField("database/password")]
# Full URI — uses the specified vault, ignoring the source vault
api_key: Annotated[str, OPField("op://other-vault/api/key")]
Authentication
Authentication is resolved in order:
- Explicit
authparameter (a service account token string orDesktopAuthinstance) OP_SERVICE_ACCOUNT_TOKENenvironment variableOP_ACCOUNT_NAMEenvironment variable (usesDesktopAuth)
You can also pass a pre-configured client directly instead of using auth.
Aliases
The source respects pydantic's alias, validation_alias, and AliasChoices when emitting keys, so resolved secrets integrate with your existing alias configuration.
Metadata
Release files for pydantic-settings-op 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pydantic_settings_op-0.1.0.tar.gz | 5.2 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydantic_settings_op-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / pydantic_settings_op-0.1.0.tar.gz
| Download URL | pydantic_settings_op-0.1.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
10e4a2bab9400566e84137011df4b25420d0d74aebe70354befd9f58b7164624
|
|
BLAKE2b-256 checksum How to use checksums |
218ab844f44fa4e18f0982f21673eb062aa34ceae49b67f1faaa087c7c6e3c38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pydantic_settings_op-0.1.0-py3-none-any.whl
| Download URL | pydantic_settings_op-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f84b80caaa127f772c88ddd8b854ce47ba451cf684419b73bddf45c8f01c0d8
|
|
BLAKE2b-256 checksum How to use checksums |
d66f45967f8bb6c21684a35f70054ece63ddffd2789ae07a511ae6e0de2ac961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pydantic-settings-op 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.