Skip to content

Conversation

@avendesora
Copy link
Owner

@avendesora avendesora commented Jan 24, 2026

Description

This PR resolves #235

Checklist:

  • I have read the CONTRIBUTING document.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have run pre-commit locally prior to submission and fixed any errors/warnings.
  • I have run tests locally prior to submission and they are passing.
  • I have added necessary documentation (if appropriate).
  • I have updated the README (if appropriate).
  • I have updated the CHANGELOG (if appropriate).
  • I have updated the version number (if appropriate).
  • I have updated the requirements (if appropriate).

Summary by Sourcery

Tests:

  • Add parameterized parser tests to verify correct normalization of Jonah-related book range abbreviations (e.g., micah-jon, jon-jon, obadiah-jon, jon-john).

Summary by Sourcery

Resolve incorrect parsing of Jonah and John book abbreviations and add regression tests for Jonah-related reference ranges.

Bug Fixes:

  • Fix misclassification of Jonah abbreviations as John by tightening the John abbreviation regular expression.

Tests:

  • Add parameterized parser tests covering Jonah-related book range abbreviations such as micah-jon, jon-jon, obadiah-jon, and jon-john.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 24, 2026

Reviewer's Guide

Adds regression tests for Jonah-related book range abbreviations and tightens the regex for matching John so that Jonah (and similar) abbreviations are parsed correctly without being misclassified as John, plus an updated dependency lockfile.

Sequence diagram for parsing Jonah-related book range abbreviations

sequenceDiagram
    actor User
    participant Parser
    participant BookPatternMatcher
    participant JohnRegex
    participant JonahRegex

    User->>Parser: parse_reference_string("micah-jon")
    Parser->>BookPatternMatcher: tokenize_and_match_books("micah-jon")

    BookPatternMatcher->>JonahRegex: test("jon")
    JonahRegex-->>BookPatternMatcher: match(Jonah)

    BookPatternMatcher->>JohnRegex: test("jon")
    JohnRegex-->>BookPatternMatcher: no_match

    BookPatternMatcher-->>Parser: [Micah, Jonah]
    Parser-->>User: ParsedRange(Micah, Jonah)
Loading

File-Level Changes

Change Details Files
Add regression tests covering Jonah-related book range abbreviations to ensure correct normalization of parsed references.
  • Introduce a parameterized pytest that feeds various Jonah-inclusive range strings through the parser
  • Assert that bible.get_references returns a single NormalizedReference with the correct start and end books for each case
  • Document the test as a regression for Issue 235 and describe the given/when/then expectations in the docstring and comments
pythonbible/tests/parser/parser_test.py
Refine the John book-matching regular expression so Jonah (and related abbreviations) are no longer incorrectly matched as John.
  • Extend the negative lookahead in the John regex to also exclude the letter 'n', preventing short forms like 'jon' from resolving to John
  • Keep existing exclusions for Joshua, Job, Jonah, and Joel while preserving other valid John abbreviations
pythonbible/pythonbible/books.py
Update the dependency lockfile to reflect the current environment/tooling state.
  • Regenerate or modify uv.lock in line with current dependencies or tooling versions
pythonbible/uv.lock

Assessment against linked issues

Issue Objective Addressed Explanation
#235 Fix parsing so that the abbreviation 'jon' is correctly interpreted as Jonah (not John), avoiding errors for inputs like 'micah-jon' and 'jon-jon' while preserving correct behavior for 'obadiah-jon' and 'jon-john'.
#235 Add regression tests covering Jonah-related range abbreviations (e.g., 'micah-jon', 'jon-jon', 'obadiah-jon', 'jon-john') to ensure the behavior remains correct.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codacy-production
Copy link

codacy-production bot commented Jan 25, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.00% 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5a516cb) 2085 2085 100.00%
Head commit (8384254) 2101 (+16) 2101 (+16) 100.00% (+0.00%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#236) 28 28 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

@avendesora avendesora marked this pull request as ready for review January 25, 2026 02:10
@avendesora avendesora requested a review from Copilot January 25, 2026 02:11
@avendesora avendesora enabled auto-merge (squash) January 25, 2026 02:11
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The _JOHN_REGULAR_EXPRESSION negative lookahead is becoming quite dense (e.g., shua|b|nah|el|n); consider adding an inline comment or extracting the excluded suffixes into a named helper to make the intent and future maintenance clearer.
  • Given that the Jonah collision arises from Jo-style abbreviations, you might want to review whether adding word boundaries or more explicit tokenization around book abbreviations would be a more robust long-term approach than continuing to extend the negative lookahead list.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `_JOHN_REGULAR_EXPRESSION` negative lookahead is becoming quite dense (e.g., `shua|b|nah|el|n`); consider adding an inline comment or extracting the excluded suffixes into a named helper to make the intent and future maintenance clearer.
- Given that the Jonah collision arises from `Jo`-style abbreviations, you might want to review whether adding word boundaries or more explicit tokenization around book abbreviations would be a more robust long-term approach than continuing to extend the negative lookahead list.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

Copilot AI left a comment

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 issue #235 where the abbreviation "Jon" for the book of Jonah was incorrectly being matched by the JOHN regex pattern, causing parsing errors when used in book ranges like "micah-jon" or "jon-jon".

Changes:

  • Updated the JOHN regular expression to exclude matching "Jo" when followed by "n", preventing conflicts with the Jonah abbreviation "Jon"
  • Added comprehensive parameterized tests covering all reported cases where "Jon" abbreviation was causing issues
  • Bumped package version from 0.15.3 to 0.15.4

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
pythonbible/books.py Modified _JOHN_REGULAR_EXPRESSION to add |n to the negative lookahead, preventing "Jon" from matching JOHN
tests/parser/parser_test.py Added parameterized test test_issue_235_jonah_abbreviation covering all four reported edge cases with Jonah abbreviation
uv.lock Updated package version to 0.15.4

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

@avendesora avendesora disabled auto-merge January 25, 2026 03:31
@avendesora avendesora merged commit 0d96daf into main Jan 25, 2026
8 of 9 checks passed
@avendesora avendesora deleted the issue/235-error-getting-reference-to-jonah branch January 25, 2026 03:31
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.

Error getting reference to Jonah

2 participants