fix(verify_pdf): --ascii-dates needs digit boundaries around the year (#512)

_YEAR matched (19|20)\d{2} anywhere, so `2000` inside `120000` or `12000`
made a budget or throughput range typed with `--` read as an en-dashed
date range: "Grew budget DKK 120000-200000" and "12000-15000 events/s"
both failed /apply Step 5d, and the agent was sent to fix a date argument
that does not exist. The guide promises a numeric range with no year is
left alone.

Bound the year with (?<!\d) and (?!\d). "2016-2024" next to a longer
number is still caught. Two new cases; the numeric one fails on the
unbounded pattern.
This commit is contained in:
Ayobami Adegoke authored and GitHub committed 2026-10-03 19:33:48 +02:00
1 parent 27a9b4a91d
commit 52f84e0f82
3 files changed
+21 -1

No files matched your search

+8
View File
@@ -15,6 +15,14 @@ per-file diff commands.
### Fixed
- **`verify_pdf.py --ascii-dates` no longer reads a year-like run inside a longer number as a
date** - the year pattern had no digit boundaries, so `2000` inside `120000` or `12000` made
`Grew budget DKK 120000–200000` and `12000–15000 events/s` fail `/apply` Step 5d as
en-dashed date ranges, and the agent was sent to fix a "date argument" that does not exist.
The guide promises a numeric range with no year is left alone; now it is. `2016–2024` next to
a longer number is still caught. Two new `test_verify_pdf.py` cases; the numeric one fails
on the unbounded pattern.
- **`check_framework_version.py`'s git diff read no longer crashes on non-ASCII framework-file
content** (`tools/check_framework_version.py`) - `run_git()` called
`subprocess.run(text=True)` without an explicit `encoding`, so output decoded via the host
+10
View File
@@ -99,6 +99,16 @@ class FindNonAsciiDateRangesTests(unittest.TestCase):
# 05-cv-templates.md keeps `--` in prose ranges like EUR 600k--1M.
self.assertEqual(find_non_ascii_date_ranges("EUR 600k\u20131M, 12\u201315 people"), [])
def test_year_like_digits_inside_a_longer_number_are_not_a_year(self):
# `2000` sits inside `120000`, `200000`, `12000`, `15000`: a budget or
# throughput range typed with `--` is not a date and must not fail 5d.
for text in ("Grew budget DKK 120000\u2013200000", "Scaled ingestion from 12000\u201315000 events/s"):
with self.subTest(text=text):
self.assertEqual(find_non_ascii_date_ranges(text), [])
def test_a_standalone_year_next_to_a_longer_number_is_still_caught(self):
self.assertEqual(find_non_ascii_date_ranges("2016\u20132024 (120000 users)")[0][1], "\u2013")
def test_year_ending_a_line_is_not_joined_to_the_next_lines_dash(self):
text = "Heading 1988-1994\n\u2013 note\n"
self.assertEqual(find_non_ascii_date_ranges(text), [])
+3 -1
View File
@@ -94,7 +94,9 @@ def normalize_text(text):
# rest are the other Unicode dashes and the minus sign, which a parser that splits
# a range only on U+002D treats the same way.
NON_ASCII_DASHES = "\u2010\u2011\u2012\u2013\u2014\u2015\u2212"
_YEAR = r"(?:19|20)\d{2}"
# A year is four digits standing alone: without the digit boundaries, `2000`
# inside `120000` or `12000` made a budget or throughput range read as a date.
_YEAR = r"(?<!\d)(?:19|20)\d{2}(?!\d)"
# Horizontal whitespace only between the year and the dash: `\s*` also matched
# a newline, so a year ending one line joined a dash opening the next (a bullet,
# a wrapped prose line) and an ASCII date was reported as U+2013.