Skip to content

Add type aliases for function signatures and improve type safety across RDKit/Bingo backends - #24

Merged
asiomchen merged 9 commits into
mainfrom
func-types
Mar 1, 2026
Merged

asiomchen merged 9 commits into
mainfrom
func-types

Conversation

@asiomchen

@asiomchen asiomchen commented Mar 1, 2026 •

Copy link
Copy Markdown
Owner

New type alias modules (_types.py):

  • src/molalchemy/rdkit/functions/_types.py — AnyRdkitMolLike, AnyRdkitFingerprintLike, AnyRdkitReactionLike, etc.
  • src/molalchemy/bingo/functions/_types.py — AnyBingoMolLike, AnyBingoReactionLike, etc.
  • These aliases accept SQLAlchemy Column, Mapped, InstrumentedAttribute, Function, and literal Python types
    (str/bytes), making function signatures accurate for real-world usage.

Function signature improvements:

  • All auto-generated functions in general.py and internal.py (both backends) now use the new type aliases instead of
    raw str | sqltypes.Text | bytes unions.
  • gen_functions.py updated to auto-resolve Rdkit* types to Any*Like aliases during code generation.
  • Bingo function docstrings fixed: "rdkit cartridge" → "bingo cartridge" in many places.
  • Renamed generic arg_1 parameters to semantic names (mol, rxn, query) where applicable.

Bug fixes & improvements:

  • SQL injection fix in bingo/comparators.py: replaced f-string interpolation in text() with bindparams().
  • Missing eq added to BingoRxnComparator.
  • Missing tanimoto() added to RdkitFPComparator.
  • New is_substructure_of() added to RdkitMolComparator (<@ operator).
  • Duplicate branches fixed in RdkitMol.column_expression and RdkitReaction.column_expression (collapsed "mol" and
    "bytes" cases).
  • Better SMILES validation in RdkitMol.bind_processor — now raises ValueError with the invalid string.
  • repr added to all custom types (RdkitMol, RdkitBitFingerprint, RdkitSparseFingerprint, RdkitReaction, BingoMol,
    BingoBinaryMol, BingoReaction, BingoBinaryReaction).
  • LSP fix: get_col_spec methods now accept **kwargs: Any to match the base class signature.
  • Removed stale bingo_func/bingo_rxn_func from bingo all.

Tests:

  • New tests/bingo/functions/test_types.py with import, usage, and backward compatibility tests (7 tests, all passing).

Other:

  • Updated tutorial notebooks with new Docker images.

@codecov

codecov Bot commented Mar 1, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.04651% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.59%. Comparing base (73d98a1) to head (2459ad0).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/molalchemy/bingo/functions/general.py 40.00% 12 Missing ⚠️
src/molalchemy/rdkit/types.py 63.63% 6 Missing and 2 partials ⚠️
src/molalchemy/bingo/comparators.py 50.00% 4 Missing ⚠️
src/molalchemy/bingo/types.py 83.33% 3 Missing ⚠️
src/molalchemy/rdkit/comparators.py 60.00% 2 Missing ⚠️
src/molalchemy/helpers.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
+ Coverage   77.99%   78.59%   +0.60%     
==========================================
  Files          19       21       +2     
  Lines        1463     1537      +74     
  Branches       27       26       -1     
==========================================
+ Hits         1141     1208      +67     
- Misses        314      321       +7     
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@asiomchen
asiomchen merged commit b8d2080 into main Mar 1, 2026
16 checks passed
@asiomchen
asiomchen deleted the func-types branch March 21, 2026 12:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant