Skip to content

Conversation

@rlskoeser
Copy link
Member

@rlskoeser rlskoeser commented Apr 11, 2025

  • seleucid
  • julian
  • allow weekdays when parsing
  • exploratory notebook with pgp dates + undate

Summary by CodeRabbit

  • New Features

    • Added support for Seleucid calendar date conversion.
    • Introduced a new property to display the weekday for dates.
    • Enabled parsing of Hebrew and Islamic dates that include weekday names and support variant month spellings.
    • Added a method to reinterpret dates under a different calendar system without conversion.
  • Bug Fixes

    • Improved error messages for unsupported date comparisons, providing clearer context.
  • Tests

    • Expanded test coverage for Hebrew and Islamic date parsing with weekdays and month-level precision.
    • Added tests to verify weekday calculation for dates.
    • Added tests for Seleucid calendar date parsing and Gregorian conversion.
    • Updated tests to check for more specific error messages in date comparisons.
  • Chores

    • Added "altair" to the optional "notebooks" dependency group.
    • Updated CI workflow to use native Python and pip commands for setup and testing.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 11, 2025

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • examples/pgp_dates.ipynb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

"""

Walkthrough

This update introduces a new Seleucid calendar converter, exposes it in the public API, and adds a corresponding calendar type. The Hebrew and Islamic date grammars are enhanced to support optional weekday prefixes and variant month spellings. The Undate and Date classes gain new methods and properties, with expanded and refined tests.

Changes

Files/Paths Change Summary
src/undate/converters/calendars/init.py, src/undate/converters/calendars/seleucid.py Added SeleucidDateConverter class for Seleucid-to-Gregorian conversion; exposed it in the calendars package's public API.
src/undate/converters/calendars/hebrew/hebrew.lark, src/undate/converters/calendars/islamic/islamic.lark Enhanced grammars to support optional weekday prefixes, comma separators, and variant month spellings/diacritics for Hebrew and Islamic calendars.
src/undate/converters/calendars/hebrew/transformer.py Updated transformer to use a generic Undate object and added a class attribute for the Hebrew calendar.
src/undate/date.py Added a weekday property to the Date class, returning the day of the week as an integer (Monday=0).
src/undate/undate.py Added SELEUCID to the Calendar enum, a new as_calendar method to reinterpret dates, improved error messages, and updated method docstrings and comments.
tests/test_converters/test_calendars/test_hebrew/test_hebrew_transformer.py Added tests for Hebrew date parsing with weekday prefixes and comma separators.
tests/test_converters/test_calendars/test_islamic/test_islamic_transformer.py Added a test for parsing Islamic month-level precision dates.
tests/test_date.py Added tests for the new weekday property in the Date class, validating against Python's datetime.
tests/test_undate.py Added test for as_calendar method and refined error message expectations in comparison tests for Undate objects with differing precisions.
tests/test_converters/test_calendars/test_seleucid.py Added tests for the new SeleucidDateConverter covering parsing and Gregorian date conversion accuracy.
pyproject.toml Added "altair" to the optional "notebooks" dependencies group.
.github/workflows/unit_tests.yml Updated CI workflow to use native Python and pip commands, improved caching, and upgraded Codecov action version.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SeleucidDateConverter
    participant HebrewDateConverter

    User->>SeleucidDateConverter: to_gregorian(year, month, day)
    SeleucidDateConverter->>SeleucidDateConverter: Adjust year with SELEUCID_OFFSET
    SeleucidDateConverter->>HebrewDateConverter: to_gregorian(adjusted_year, month, day)
    HebrewDateConverter-->>SeleucidDateConverter: (gregorian_year, month, day)
    SeleucidDateConverter-->>User: (gregorian_year, month, day)
Loading

Possibly related PRs

Suggested reviewers

  • robcast
  • jdamerow
  • ColeDCrawford

Poem

In the garden of code, a new seed is sown,
Seleucid dates now stand on their own!
Weekdays and months with accents and flair,
Hebrew and Islamic, all handled with care.
With weekdays to count and calendars to swap,
This bunny’s delight just won’t stop!
🐇✨
"""


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rlskoeser rlskoeser marked this pull request as ready for review May 22, 2025 22:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
src/undate/converters/calendars/hebrew/transformer.py (1)

6-9: Consider deprecating the HebrewUndate class

The HebrewUndate class appears to be unused now that you're returning a generic Undate with a calendar parameter. If it's no longer needed, consider deprecating or removing it to avoid confusion.

-class HebrewUndate(Undate):
-    """Undate convience subclass; sets default calendar to Hebrew."""
-
-    calendar = Calendar.HEBREW
-
src/undate/converters/calendars/seleucid.py (1)

1-24: Add validation for month and day parameters

The implementation assumes all Seleucid dates use the same month structure as Hebrew dates. Consider adding validation for month and day parameters to ensure they're within valid ranges for the Seleucid calendar.

def to_gregorian(self, year: int, month: int, day: int) -> tuple[int, int, int]:
    """Convert a Seleucid date, specified by year, month, and day,
    to the Gregorian equivalent date. Uses hebrew calendar conversion
    logic with :attr:`SELEUCID_OFFSET`. Returns a tuple of year, month, day.
    """
+   # Validate month and day are within valid ranges for Seleucid calendar
+   if not 1 <= month <= 13:
+       raise ValueError(f"Month must be between 1 and 13, got {month}")
+   # Add further validation as needed
    return super().to_gregorian(year + self.SELEUCID_OFFSET, month, day)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e6fb929 and f3598c8.

📒 Files selected for processing (11)
  • src/undate/converters/calendars/__init__.py (1 hunks)
  • src/undate/converters/calendars/hebrew/hebrew.lark (3 hunks)
  • src/undate/converters/calendars/hebrew/transformer.py (2 hunks)
  • src/undate/converters/calendars/islamic/islamic.lark (4 hunks)
  • src/undate/converters/calendars/seleucid.py (1 hunks)
  • src/undate/date.py (1 hunks)
  • src/undate/undate.py (5 hunks)
  • tests/test_converters/test_calendars/test_hebrew/test_hebrew_transformer.py (1 hunks)
  • tests/test_converters/test_calendars/test_islamic/test_islamic_transformer.py (1 hunks)
  • tests/test_date.py (2 hunks)
  • tests/test_undate.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
tests/test_converters/test_calendars/test_hebrew/test_hebrew_transformer.py (2)
src/undate/converters/calendars/hebrew/transformer.py (1)
  • HebrewUndate (6-9)
src/undate/date.py (1)
  • DatePrecision (143-168)
src/undate/converters/calendars/__init__.py (1)
src/undate/converters/calendars/seleucid.py (1)
  • SeleucidDateConverter (5-24)
tests/test_converters/test_calendars/test_islamic/test_islamic_transformer.py (2)
src/undate/converters/calendars/islamic/transformer.py (1)
  • IslamicUndate (6-9)
src/undate/date.py (1)
  • DatePrecision (143-168)
🔇 Additional comments (25)
tests/test_converters/test_calendars/test_islamic/test_islamic_transformer.py (1)

31-31: Good addition of month-level precision test case.

The new test case for "Rabīʿ I 490" properly validates parsing of Islamic dates with month-level precision. This complements your grammar extensions for optional weekday prefixes and improves test coverage.

src/undate/converters/calendars/__init__.py (2)

4-4: Proper import of new Seleucid calendar converter.

The import statement correctly brings in the SeleucidDateConverter class from the appropriate module.


6-11: Correctly exposed SeleucidDateConverter in public API.

The SeleucidDateConverter is properly added to the __all__ list, making it accessible to users. The organization of the list is maintained with consistent formatting.

tests/test_converters/test_calendars/test_hebrew/test_hebrew_transformer.py (1)

29-34: Well-structured test cases for weekday parsing.

The test cases thoroughly validate Hebrew date parsing with weekday prefixes, with and without comma separation. The comment about whitespace handling raises a valid question - consider whether ignoring whitespace entirely is the desired behavior, especially for edge cases.

Do you want this behavior where "Thursday12Sivan4795" parses successfully without any whitespace? While flexible parsing can be helpful, it might also allow malformed inputs to be accepted silently.

tests/test_undate.py (2)

301-304: Improved error message pattern in test assertion.

The updated regex pattern provides a more precise match for the enhanced error message. This change properly aligns the test with improvements to the error reporting in the __lt__ method.


308-311: Consistent error message pattern for reversed comparison.

The same improved pattern is correctly applied to the second test case, maintaining consistency when testing the comparison in the reverse direction.

src/undate/converters/calendars/hebrew/transformer.py (2)

16-16: Good addition of the calendar class attribute

Adding this class attribute ensures consistent calendar type usage throughout the transformer.


27-29: Nice comment fix and implementation update

The comment now correctly refers to the Hebrew calendar instead of what was likely an incorrect reference to the Islamic calendar. Using the configured calendar attribute in the Undate constructor provides better flexibility and consistency with the broader refactoring.

src/undate/date.py (1)

107-126: Well-implemented weekday property

The weekday property is implemented correctly, returning the day of week as an integer (Monday=0, Sunday=6) consistent with Python's datetime.date.weekday(). The implementation cleverly accounts for numpy's Thursday-based weeks and includes clear documentation.

One suggestion: consider adding a test for dates without day precision to verify the property returns None.

tests/test_date.py (2)

1-2: Good import addition

Adding the datetime import is necessary for comparing the weekday results with Python's built-in implementation.


56-75: Comprehensive weekday testing

The test thoroughly verifies the weekday property against Python's built-in implementation for a full week of dates, which is excellent.

Consider adding two additional test cases:

  1. Test that weekday returns None for Date objects with year or month precision
  2. Test dates in different months/years to ensure consistent behavior
def test_weekday_none():
    assert Date(2025).weekday is None
    assert Date(2025, 1).weekday is None
src/undate/converters/calendars/seleucid.py (2)

5-12: Good implementation of SeleucidDateConverter

The class is well-structured with clear documentation for the offset constant and proper attribute overrides.


13-18: Appropriate calendar type override

The override of the transformer's calendar attribute to Calendar.SELEUCID ensures proper calendar type identification throughout the system.

src/undate/converters/calendars/islamic/islamic.lark (3)

6-6: Added weekday support to Islamic date grammar

The grammar rule has been updated to include an optional weekday prefix before the day-month-year pattern. This enhancement aligns with similar changes in the Hebrew calendar grammar and improves the parsing capabilities.


33-35: Good addition of weekday and comma rules

The addition of explicit weekday and comma rules enables parsing dates with weekday prefixes. The weekday implementation properly handles all days of the week with an optional comma.


50-50: Enhanced month pattern to support variant spellings

The regex pattern for month_6 now includes [dḍ] instead of just d, allowing for variant spellings of "Jumādā" with different diacritics, which improves the robustness of the parser.

src/undate/undate.py (5)

32-32: Added Seleucid calendar support

The Calendar enum has been extended with the SELEUCID entry, enabling support for the Seleucid calendar system as mentioned in the PR objectives.


195-197: Improved docstring clarity for set_calendar method

The docstring now clearly indicates that set_calendar is intended for initialization use only and directs users to the new as_calendar method for changing calendars post-initialization.


208-219: Well-implemented as_calendar method

The new as_calendar method provides a clean way to create a new Undate instance with the same date values but a different calendar system without performing calendar conversion. This method is properly documented and maintains the original date values.


339-342: Improved error message for incomparable dates

The error message in the __lt__ method now sorts the dates by precision and includes both in the error message, providing clearer context when dates cannot be compared because one falls within another.


428-428: Corrected comment for year property

The comment has been updated to correctly specify that an unknown year string is returned when the year is unset but the precision is year or greater (not month or greater), improving documentation accuracy.

src/undate/converters/calendars/hebrew/hebrew.lark (4)

6-6: Added weekday support to Hebrew date grammar

The grammar rule has been updated to include an optional weekday prefix and optional comma before the year, enhancing parsing capabilities for Hebrew dates with weekday information.


34-36: Good addition of weekday and comma rules

The addition of explicit weekday and comma rules enables parsing dates with weekday prefixes. The implementation properly handles all days of the week with an optional comma, consistent with the Islamic calendar grammar.


50-51: Enhanced month_8 pattern for variant spellings

The regex pattern for month_8 now supports multiple variants of Heshvan (Heshvan, Ḥeshvan, Marḥeshvan), improving the robustness of the parser for different textual representations.


54-56: Improved month patterns for variant spellings

The regex patterns for month_10 and month_11 have been updated to support variant spellings with different diacritics (Tevet/Teveth and Shevat/Shevaṭ), making the parser more flexible with different textual representations.

Comment on lines +19 to +24
def to_gregorian(self, year: int, month: int, day: int) -> tuple[int, int, int]:
"""Convert a Seleucid date, specified by year, month, and day,
to the Gregorian equivalent date. Uses hebrew calendar conversion
logic with :attr:`SELEUCID_OFFSET`. Returns a tuple of year, month, day.
"""
return super().to_gregorian(year + self.SELEUCID_OFFSET, month, day)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Clean implementation of to_gregorian method

The method correctly applies the offset and delegates to the parent implementation, with clear documentation.

Consider adding unit tests for this new converter to verify the offset application is working correctly:


🏁 Script executed:

#!/bin/bash
# Search for existing tests of calendar converters to understand testing pattern
rg -A 5 "test.*converter" --type py

Length of output: 4523


Add unit tests for the Seleucid calendar converter

While the implementation of to_gregorian correctly applies SELEUCID_OFFSET, we need dedicated tests to ensure the offset is always handled as expected. Please add a new test module following the pattern in tests/test_converters/test_calendars/test_hebrew/test_hebrew_converter.py:

• Create tests/test_converters/test_calendars/test_seleucid/test_seleucid_converter.py
• Write tests for known date pairs, for example:

def test_to_gregorian_offset_applied():
    converter = SeleucidConverter()
    # e.g., Seleucid year X maps to Gregorian year X + SELEUCID_OFFSET
    assert converter.to_gregorian(1, 1, 1) == (1 + converter.SELEUCID_OFFSET, 1, 1)
    # add a few additional sample dates

• Verify edge cases (start/end of year, leap months/days if applicable)

This will ensure future changes to the offset logic are caught.

🤖 Prompt for AI Agents
In src/undate/converters/calendars/seleucid.py around lines 19 to 24, the
to_gregorian method is implemented correctly but lacks dedicated unit tests.
Create a new test file at
tests/test_converters/test_calendars/test_seleucid/test_seleucid_converter.py
following the pattern of existing calendar converter tests, such as the Hebrew
converter tests. Add test cases that instantiate the SeleucidConverter and
verify that to_gregorian correctly applies the SELEUCID_OFFSET for various known
date inputs, including edge cases like start/end of year and any leap months or
days if relevant.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/unit_tests.yml (1)

56-58: Use with: input for the Codecov token
The v4 Codecov Action supports a token input under with:. Switching from env to with: makes the intent explicit and aligns with the action’s documentation.

-        env:
-          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
+        with:
+          token: ${{ secrets.CODECOV_TOKEN }}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 57e3578 and c1dfef9.

📒 Files selected for processing (1)
  • .github/workflows/unit_tests.yml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/unit_tests.yml

55-55: could not parse as YAML: yaml: line 55: mapping values are not allowed in this context

(syntax-check)

🪛 YAMLlint (1.37.1)
.github/workflows/unit_tests.yml

[error] 55-55: syntax error: mapping values are not allowed here

(syntax)

@rlskoeser rlskoeser force-pushed the feature/pgp-dates branch from c1dfef9 to 44a3370 Compare May 22, 2025 22:30
@rlskoeser rlskoeser force-pushed the feature/pgp-dates branch from fa23d5f to 8b3030b Compare May 23, 2025 13:38
@codecov
Copy link

codecov bot commented May 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.74%. Comparing base (759d0c7) to head (af35f81).
⚠️ Report is 134 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #125      +/-   ##
===========================================
+ Coverage    96.50%   98.74%   +2.23%     
===========================================
  Files           20       37      +17     
  Lines          658     1588     +930     
===========================================
+ Hits           635     1568     +933     
+ Misses          23       20       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rlskoeser rlskoeser requested a review from robcast May 23, 2025 13:43
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
tests/test_converters/test_calendars/test_seleucid.py (1)

59-110: 🛠️ Refactor suggestion

Clean up extensive commented-out code.

There's a significant amount of commented-out test code that appears to cover important functionality like leap year handling, edge cases, and comparison with Hebrew calendar conversion. This commented code should either be:

  1. Implemented as proper tests if the functionality is needed
  2. Removed entirely if it's obsolete or moved elsewhere

The commented code suggests more comprehensive test coverage was planned, including:

  • Leap year and leap day handling
  • Comparison with Hebrew calendar offsets
  • Additional date conversion edge cases

Consider this approach to address the commented code:

-# TODO: update validation error to say seleucid instead of hebrew
-
-#     seleucid_year = 1458
-#     converted_date = convert_seleucid_date(f"Tishri {seleucid_year}")
-# ... [extensive commented code] ...
+    def test_leap_year_handling(self):
+        """Test leap year and leap day conversion."""
+        # Implement the leap year tests from commented code
+        pass
+    
+    def test_offset_consistency_with_hebrew(self):
+        """Test that Seleucid offset calculations are consistent with Hebrew calendar."""
+        # Implement the Hebrew calendar comparison tests
+        pass

This will improve test coverage and code maintainability by either implementing the planned tests or removing unnecessary comments.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90c95a1 and 8b3030b.

📒 Files selected for processing (2)
  • .github/workflows/unit_tests.yml (1 hunks)
  • tests/test_converters/test_calendars/test_seleucid.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/unit_tests.yml
🔇 Additional comments (3)
tests/test_converters/test_calendars/test_seleucid.py (3)

1-4: LGTM: Clean and appropriate imports.

The imports are well-organized and include all necessary components for testing the SeleucidDateConverter functionality.


6-31: LGTM: Comprehensive parsing tests with good coverage.

The test_parse method effectively tests parsing at all precision levels (day, month, year) and validates all relevant properties of the resulting Undate objects. The assertions properly verify calendar type, precision, and label formatting.


32-55: LGTM: Thorough Gregorian conversion validation.

The test_gregorian_earliest_latest method properly tests the conversion from Seleucid to Gregorian dates, including both specific date conversions and date ranges for month/year precision. The test cases cover different months (Elul, Adar I, Tishri) and validate the earliest/latest date logic.

assert date.label == f"{date_str} {SeleucidDateConverter.calendar_name}"


# TODO: update validation error to say seleucid instead of hebrew
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Address the TODO: Fix validation error messaging.

The TODO comment indicates that validation errors may incorrectly reference "Hebrew" instead of "Seleucid" calendar. This should be investigated and fixed to ensure proper error messaging.

Run this script to check for validation error messages that mention Hebrew when they should mention Seleucid:

Do you want me to help investigate and fix the validation error messaging?


🏁 Script executed:

#!/bin/bash
# Description: Search for validation error messages in SeleucidDateConverter that might incorrectly reference Hebrew calendar

# Search for error messages in the Seleucid converter
ast-grep --pattern 'class SeleucidDateConverter {
  $$$
}'

# Also search for error messages that mention Hebrew in the context of Seleucid
rg -A 3 -B 3 "Hebrew" src/undate/converters/calendars/seleucid.py

Length of output: 377


🏁 Script executed:

#!/bin/bash
# Locate the HebrewDateConverter class and its validation/error logic
rg -n "class HebrewDateConverter" -A20 src/undate/converters/calendars/hebrew.py
rg -n "def validate" -A5 -B2 src/undate/converters/calendars/hebrew.py
rg -n "raise ValueError" -A3 -B3 src/undate/converters/calendars/hebrew.py

Length of output: 478


#!/bin/bash
set -e

# 1. Find any converter file with 'hebrew' in its name
echo "=== Files matching *hebrew*.py ==="
find src/undate/converters/calendars -type f -iname "*hebrew*.py" || echo "No files found."

# 2. Locate the class HebrewDateConverter to confirm its file path
echo
echo "=== Locating class HebrewDateConverter ==="
rg -n "class HebrewDateConverter" -A5 -B2 src/undate/converters/calendars/*.py || echo "Definition not found in calendars folder."

# 3. Inspect ValueError raises and literal 'Hebrew' in that file
echo
echo "=== Inspecting error messages in the Hebrew converter ==="
rg -n "raise ValueError" -A3 -B3 src/undate/converters/calendars/*hebrew*.py || echo "No ValueError calls found."
rg -n "\"Hebrew\"" -A1 -B1 src/undate/converters/calendars/*hebrew*.py || echo "No 'Hebrew' literals found."

#!/usr/bin/env bash
set -e

echo "=== 1. Locate HebrewDateConverter definition across the repo ==="
rg -n "class HebrewDateConverter" --glob '*.py' || echo "No class definition found."

echo
echo "=== 2. List all files mentioning HebrewDateConverter ==="
rg -l "HebrewDateConverter" --glob '*.py' || echo "No references found."

echo
echo "=== 3. Inspect the converter file for error messages referencing 'Hebrew' or raising ValueError ==="
file=$(rg -l "class HebrewDateConverter" --glob '*.py' | head -n1)
if [ -n "$file" ]; then
  echo "Inspecting $file"
  rg -n "\"Hebrew\"" -A3 -B3 "$file" || echo "No 'Hebrew' literals in $file."
  rg -n "raise ValueError" -A3 -B3 "$file" || echo "No ValueError raises in $file."
else
  echo "Cannot inspect: HebrewDateConverter file not found."
fi

#!/usr/bin/env bash
set -e

echo "=== 1. List all DateConverter classes across the repo ==="
rg -n "class .*DateConverter" -A2 -B0 --glob '*.py' || echo "No DateConverter classes found."

echo
echo "=== 2. Locate HebrewDateConverter definition ==="
hebrew_file=$(rg -l "class HebrewDateConverter" --glob '*.py' | head -n1 || true)
if [ -n "$hebrew_file" ]; then
  echo "Found HebrewDateConverter in: $hebrew_file"
  echo
  echo "=== 3. Inspecting error messages in $hebrew_file ==="
  rg -n "raise ValueError" -A3 -B3 "$hebrew_file" || echo "No ValueError statements."
  rg -n "\"Hebrew\"" -A2 -B2 "$hebrew_file" || echo "No 'Hebrew' literals."
else
  echo "HebrewDateConverter class not found!"
fi

Fix SeleucidDateConverter validation messages

Overwrite the inherited Hebrew‐specific error text so that any ValueError in SeleucidDateConverter refers to the “Seleucid calendar” instead of “Hebrew”:

• In src/undate/converters/calendars/seleucid.py:
– Override the relevant validation methods (e.g. validate_year, validate_month, validate_day) and update their ValueError messages to mention “Seleucid calendar.”
• In tests/test_converters/test_calendars/test_seleucid.py (around line 57):
– Update assertions on exception text to expect “Seleucid calendar” in place of “Hebrew calendar.”

Please remove the TODO and ensure both implementation and tests use the correct calendar name.

🤖 Prompt for AI Agents
In tests/test_converters/test_calendars/test_seleucid.py at line 57 and in
src/undate/converters/calendars/seleucid.py, fix the validation error messages
that incorrectly mention "Hebrew" instead of "Seleucid calendar." Override the
validation methods in SeleucidDateConverter to raise ValueErrors with messages
referencing "Seleucid calendar" and update the test assertions to expect these
corrected messages. Remove the TODO comment after making these changes.

@rlskoeser rlskoeser merged commit b91fe3c into develop Jun 25, 2025
10 checks passed
@rlskoeser rlskoeser deleted the feature/pgp-dates branch June 25, 2025 17:07
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.

2 participants