Skip to content

Limit the name readings tried for date_formats - #1552

Merged
AdrianAtZyte merged 1 commit into
scrapinghub:masterfrom
serhii73:limit-date-formats-name-readings
Oct 27, 2026
Merged

AdrianAtZyte merged 1 commit into
scrapinghub:masterfrom
serhii73:limit-date-formats-name-readings

Conversation

@serhii73

Copy link
Copy Markdown
Collaborator

Follow-up to #1486.

#1486 tries every combination of the English names that the month and weekday names of the string can stand for. Each name with two meanings, such as Spanish "mar" (martes or marzo), doubles the number of combinations, so a string with many of them makes parse() with date_formats try an ever larger number of strptime calls before it returns None.

This keeps only the first _MAX_TRANSLATIONS (16) combinations, the limit #1491 already uses for the other readings of words with several meanings. The first combination is the one #1486 tried first, so strings with a few such names, like the ones in the #1486 tests, parse as before.

πŸ€– Generated with Claude Code

scrapinghub#1486 tries every combination of the English names that each month or
weekday name of the string can stand for. A name with two meanings, such
as Spanish "mar" (martes or marzo), doubles the number of combinations,
so a string with many such names made parse() with date_formats try an
ever larger number of strptime calls before giving up.

Try only the first _MAX_TRANSLATIONS combinations, the same limit that
scrapinghub#1491 uses for the other readings of words with several meanings.

Tested: a new test checks that 12 "mar" yield exactly _MAX_TRANSLATIONS
distinct readings (it got 4096 before the change); the scrapinghub#1486 tests still
pass; full suite, ruff and mypy pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

βœ… 10 untouched benchmarks


Comparing serhii73:limit-date-formats-name-readings (2c46e26) with master (b4124e0)

Open in CodSpeed

@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

βœ… All modified and coverable lines are covered by tests.
βœ… Project coverage is 99.18%. Comparing base (b4124e0) to head (2c46e26).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1552   +/-   ##
=======================================
  Coverage   99.18%   99.18%           
=======================================
  Files         239      239           
  Lines        4030     4030           
=======================================
  Hits         3997     3997           
  Misses         33       33           

β˜” View full report in Codecov by Harness.
πŸ“’ 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.

@AdrianAtZyte
AdrianAtZyte merged commit f1c58d6 into scrapinghub:master Oct 27, 2026
20 checks passed
@serhii73
serhii73 deleted the limit-date-formats-name-readings branch October 29, 2026 09:58
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