Smiles-Validator
A Pydantic validator for SMILES chemical notation that validates, sanitizes, and optionally returns either canonical or original input.
Install
pip install smiles-validator
Requires Python ≥ 3.10 · Pydantic v2 · RDKit 2024.9+
Usage
from pydantic import BaseModel
from typing import Annotated
from smiles_validator import SmilesText, SmilesValidator
class Model(BaseModel):
# Default: Canonical SMILES
canonical: SmilesText
# Keep original input
original: Annotated[str, SmilesValidator(keep_original=True)]
m = Model(
canonical="C1=CC=CC=C1",
original="C1=CC=CC=C1"
)
print(m.canonical) # => "c1ccccc1"
print(m.original) # => "C1=CC=CC=C1"
Features
- 🚀 Fast SMILES validation using RDKit
- 🔄 Canonicalization with optional original input preservation
- 📦 Pydantic v2 integration
- 📊 Comprehensive test coverage
- 🧪 CI/CD with multiple Python versions
API
SmilesValidator Class
SmilesValidator(keep_original: bool = False)
Parameters:
keep_original: IfTrue, returns the exact input string after validation. IfFalse(default), returns the canonical SMILES.
SmilesText Type
SmilesText is an alias for Annotated[str, SmilesValidator()] that automatically uses the default validator settings (canonical output).
Development
# Install dependencies
uv sync --locked --all-extras --dev
# Run tests
just test
# Run linting
just check
# Run formatting
just format
License
Acknowledgements
- Built with RDKit for chemical structure handling
- Uses Pydantic v2 for validation integration
Metadata
Release files for smiles-validator 0.1.11
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 | Actions |
|---|---|---|---|---|
| smiles_validator-0.1.11.tar.gz | 5.3 kB | With provenance | Details for smiles_validator-0.1.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| smiles_validator-0.1.11-py3-none-any.whl | Python 3 | none | any | Details for smiles_validator-0.1.11-py3-none-any.whl |
Total release size: 10.2 kB
Release files / smiles_validator-0.1.11.tar.gz
| Download URL | smiles_validator-0.1.11.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9b7b9a04193d6e212ebd8eff65646e1360d359ee6fe04efa25c2f1e2a3a609e
|
|
BLAKE2b-256 checksum How to use checksums |
42d81d50a20a89e244d996cd0d91907c535e9a01901137ee4fed1f184243527a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2025.
Transparency logRelease files / smiles_validator-0.1.11-py3-none-any.whl
| Download URL | smiles_validator-0.1.11-py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b154bd9d24ebdf5f5668cbd3fcea75d39a68423ed8db930437909702fc0b305
|
|
BLAKE2b-256 checksum How to use checksums |
2b073f240a120f18a06ed5ba4f450a93d785c52cfd44ef82fa2c5d07f779713f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2025.
Transparency logSecurity for smiles-validator 0.1.11
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for smiles_validator-0.1.11.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2025.
Transparency logA 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.