Skip to content

Fix PEP 701 multi-line f-strings breaking Python 3.10/3.11 import#249

Open
sanjey99 wants to merge 1 commit into
domokane:masterfrom
sanjey99:fix/bond-fstring-py310-py311
Open

Fix PEP 701 multi-line f-strings breaking Python 3.10/3.11 import#249
sanjey99 wants to merge 1 commit into
domokane:masterfrom
sanjey99:fix/bond-fstring-py310-py311

Conversation

@sanjey99

Copy link
Copy Markdown

Fixes #248

bond.py used a PEP 701 multi-line replacement field inside an f-string, a Python 3.12+ only feature, which is a hard SyntaxError on 3.10/3.11 even though pyproject.toml declares requires-python = ">=3.10,<3.14". This breaks financepy.products.bonds and everything importing it transitively.

This applies fix option 1 from the issue (keep the replacement field on one line, so 3.10/3.11 stays supported) rather than bumping the minimum Python version.

While verifying the fix, found a second instance of the exact same pattern at line ~1548 (OAS-calculation warning) that wasn't mentioned in the issue, and fixed that too.

Testing

Package imports and compiles cleanly on Python 3.11. unit_tests/test_FinBond.py (8 tests) and the full bond-related suite (61 tests) pass.

bond.py used a PEP 701 multi-line replacement field inside an f-string
(Python 3.12+ only), which is a SyntaxError on 3.10/3.11 despite
pyproject.toml declaring requires-python = ">=3.10,<3.14". This took
down financepy.products.bonds and everything importing it transitively
on those interpreters.

Found and fixed a second instance (OAS warning, line ~1548) beyond the
one reported in domokane#248, matching the same pattern.

Fixes domokane#248
Copilot AI review requested due to automatic review settings July 24, 2026 08:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a Python 3.10/3.11 import-time SyntaxError in financepy.products.bonds by removing PEP 701 (Python 3.12+) multi-line f-string replacement fields in bond.py, restoring compatibility with the project’s declared requires-python >=3.10.

Changes:

  • Fix YTM convergence warning f-string to keep the replacement field on a single line (Python 3.10/3.11 compatible).
  • Fix OAS convergence warning f-string with the same multi-line replacement-field pattern.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

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

2 participants