Conversation
…ames (avendesora#168) Fixes examples reported in avendesora#168 such as 'Micah. 2Ch. 34:20', 'Psalm. 46', 'Psalms. 74', and '1Peter. 1:22'. The parser now strips punctuation after the matched book name before interpreting chapter and verse values, avoiding empty-string int conversion errors.
Contributor
Reviewer's GuideThe parser now strips leading whitespace and punctuation from reference segments before interpreting chapter/verse values, preventing empty-string conversion failures for book names followed by periods while retaining existing range handling. Parameterized regression tests cover the reported forms, and the fix is documented in the changelog. Flow diagram for parsing references with trailing periodsflowchart LR
A["Reference segment"] --> B["strip and lstrip punctuation"]
B --> C["remove trailing DASH"]
C --> D["replace PERIOD with COLON"]
D --> E["split chapter and verse"]
E --> F["parse normalized reference"]
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pythonbible/pythonbible/parser.py" line_range="163-166" />
<code_context>
- if (not sub_reference or sub_reference in {DASH, PERIOD}) and not references:
+ normalized_sub_reference = sub_reference.strip().lstrip(" .,:;-")
+
+ if (
+ not normalized_sub_reference
+ or normalized_sub_reference in {DASH, PERIOD}
+ ) and not references:
references.append(NormalizedReference(book, None, None, None, None, book))
continue
</code_context>
<issue_to_address>
**nitpick:** The `normalized_sub_reference in {DASH, PERIOD}` check can never match `PERIOD`: `lstrip(" .,:;-")` converts a period-only value to an empty string before the condition is evaluated. The unreachable `PERIOD` branch leaves contradictory punctuation handling in this control flow and can mislead future changes to the parser.
**Suggested fix:** Remove `PERIOD` from the set or check the punctuation-only value before stripping it.
```suggestion
if (
not normalized_sub_reference
or normalized_sub_reference in {DASH}
) and not references:
```
</issue_to_address>Sourcery assessment
Approved.
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
This branch has not been deployed
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.
…ames (#168)
Fixes examples reported in #168 such as 'Micah. 2Ch. 34:20', 'Psalm. 46', 'Psalms. 74', and '1Peter. 1:22'. The parser now strips punctuation after the matched book name before interpreting chapter and verse values, avoiding empty-string int conversion errors.
Description
Fixes #168
I wanted to test out AI and it's ability to fix bugs.
Checklist:
Summary by Sourcery
Handle punctuation after Bible book names so affected references parse correctly.
Bug Fixes:
Tests: