Skip to content

Python 3.10/3.11: bonds package fails to import — multi-line f-string needs 3.12 (declared support is >=3.10) #248

Description

@DMZ22

financepy/products/bonds/bond.py line 1238 contains an f-string whose replacement field spans two lines:

print(f"Warning: YTM calculation did not converge for price {
        dirty_price}")

Multi-line expressions inside f-strings are a PEP 701 feature, available only on Python 3.12+. On Python 3.10 and 3.11 this is a SyntaxError at import time:

File ".../financepy/products/bonds/bond.py", line 1238
SyntaxError: unterminated string literal (detected at line 1238)

and it takes down the whole financepy.products.bonds package (its __init__.py imports bond), plus everything that imports bonds transitively — on 3.11, 17 unit-test modules fail collection for this reason (that's how I ran into it while testing #247).

Why it slips through:

  • pyproject.toml declares requires-python = ">=3.10,<3.14", so pip installs happily on 3.10/3.11 where the import then fails.
  • run-unit-tests.yml pins a single PYTHON_VERSION: '3.13.9', so CI never exercises the older interpreters. The line came in with e38db05 (Nov 2025).

Fix options:

  1. Put the replacement field on one line (one-line change) — keeps 3.10/3.11 support; or
  2. Declare reality and bump requires-python to >=3.12.

If you'd like option 1, happy to send the trivial PR; adding the minimum supported version to the CI matrix would keep this from regressing either way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions