Fix PEP 701 multi-line f-strings breaking Python 3.10/3.11 import#249
Open
sanjey99 wants to merge 1 commit into
Open
Fix PEP 701 multi-line f-strings breaking Python 3.10/3.11 import#249sanjey99 wants to merge 1 commit into
sanjey99 wants to merge 1 commit into
Conversation
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
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #248
bond.pyused 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.