Python wrapper around the 1Password CLI with Pydantic Settings integration
Project description
1Password CLI Python Wrapper
Python wrapper for 1Password CLI with Pydantic Settings integration. Automatically injects secrets from op:// references while preserving types.
Features
- Automatic secret injection with
op://reference detection - Pydantic Settings integration with pre-validation injection
- Type preservation (int, float, bool, None, lists)
- Full type hints with
py.typedmarker - Performance optimized (skips CLI calls when no secrets detected)
- Timeout protection and clear error messages
Installation
pip install 1password-cli
Prerequisites: 1Password CLI installed and authenticated (op signin)
Usage
String injection:
from scottzach1.onepassword_cli import inject_string_1password
password = inject_string_1password("op://vault/database/password")
Dictionary injection:
from scottzach1.onepassword_cli import inject_dictionary_1password
config = {
"database_url": "op://vault/database/url",
"api_key": "op://vault/api/key",
"port": 5432, # Non-secret values preserved
}
injected = inject_dictionary_1password(config)
Pydantic Settings:
from scottzach1.onepassword_cli import OnePasswordSettings
class AppSettings(OnePasswordSettings):
database_url: str = "op://vault/database/url"
api_key: str = "op://vault/api/key"
port: int = 8080
settings = AppSettings() # Secrets injected automatically
API
inject_string_1password(value, check_cli=True)- Inject secrets into a stringinject_dictionary_1password(data, check_cli=True, in_place=False)- Inject secrets into a dictionaryOnePasswordSettings- Pydantic Settings base class with automatic injection
See docstrings for parameters and exceptions.
Development
# Setup
uv sync --dev && uv run pre-commit install
# Test
uv run pytest tests/ -v -m "not integration"
uv run coverage run -m pytest tests/ -m "not integration"
# Lint/Format
uv run ruff check src/ tests/ --fix
uv run ruff format src/ tests/
License
MIT License - see LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file 1password_cli-0.0.1.tar.gz.
File metadata
- Download URL: 1password_cli-0.0.1.tar.gz
- Upload date:
- Size: 68.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a277c66acc10e46f92f71df2af751eceee6e52354a6dee9d108b0ef339f52bb9
|
|
| MD5 |
5d2d208103c50feacd4fc20ea33f41f5
|
|
| BLAKE2b-256 |
197afc4c69b583d479fee5645080e4f1bd70c6df4b016447217f473ef9a54368
|
Provenance
The following attestation bundles were made for 1password_cli-0.0.1.tar.gz:
Publisher:
pipeline.yml on scottzach1/1Password-CLI-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
1password_cli-0.0.1.tar.gz -
Subject digest:
a277c66acc10e46f92f71df2af751eceee6e52354a6dee9d108b0ef339f52bb9 - Sigstore transparency entry: 845687268
- Sigstore integration time:
-
Permalink:
scottzach1/1Password-CLI-Python@ad715505a4da10c16b9dd70f9576141658d2c650 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/scottzach1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yml@ad715505a4da10c16b9dd70f9576141658d2c650 -
Trigger Event:
push
-
Statement type:
File details
Details for the file 1password_cli-0.0.1-py3-none-any.whl.
File metadata
- Download URL: 1password_cli-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22cc63c8973a8e70900e9e4c38c1e5495aaefcca8d6135e80af596f02abc89e6
|
|
| MD5 |
b61fe3e4de20b6b35dd495f7cc984f6b
|
|
| BLAKE2b-256 |
09ff6fd72ca55d5bff66ba87c5867ce96533d28e3c6b9d9ea8811a35b0d0e205
|
Provenance
The following attestation bundles were made for 1password_cli-0.0.1-py3-none-any.whl:
Publisher:
pipeline.yml on scottzach1/1Password-CLI-Python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
1password_cli-0.0.1-py3-none-any.whl -
Subject digest:
22cc63c8973a8e70900e9e4c38c1e5495aaefcca8d6135e80af596f02abc89e6 - Sigstore transparency entry: 845687270
- Sigstore integration time:
-
Permalink:
scottzach1/1Password-CLI-Python@ad715505a4da10c16b9dd70f9576141658d2c650 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/scottzach1
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pipeline.yml@ad715505a4da10c16b9dd70f9576141658d2c650 -
Trigger Event:
push
-
Statement type: