Skip to main content

Smiles-Validator

Test Coverage Python PyPI version License CI Code Style

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: If True, returns the exact input string after validation. If False (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

MIT License · GitHub

Acknowledgements

  • Built with RDKit for chemical structure handling
  • Uses Pydantic v2 for validation integration

Metadata

Release files for smiles-validator 0.1.9

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

Source distribution (sdist)

Source distribution for smiles-validator 0.1.9
File Size Uploaded Provenance Actions
smiles_validator-0.1.9.tar.gz 5.3 kB With provenance Details for smiles_validator-0.1.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for smiles-validator 0.1.9
File Interpreter ABI Platform Actions
smiles_validator-0.1.9-py3-none-any.whl Python 3 none any Details for smiles_validator-0.1.9-py3-none-any.whl

Total release size: 10.2 kB

Release files / smiles_validator-0.1.9.tar.gz

Download URL smiles_validator-0.1.9.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9816f625c5c4448d85cb836ca7f9f6481dc946281373b679c92fe5f26ea44253
BLAKE2b-256 checksum
How to use checksums
1e7f428f9e77f4ffa64c68507767727948b092494695f868ac0281cc09d5ffbb
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 log

Release files / smiles_validator-0.1.9-py3-none-any.whl

Download URL smiles_validator-0.1.9-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
873734fc8f7db11bb5dd31bd86bae3ab91fa709c77f3e62369a4c7b4675979a4
BLAKE2b-256 checksum
How to use checksums
6ba4b19b27b22b96efab281d317c5f4974653ec52b883b8c91e0f2f6839d103a
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 log

Security for smiles-validator 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for smiles_validator-0.1.9.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 log

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.

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