Skip to content

Commit

Permalink
Fix a regression with Consecutives / OneOfASet
Browse files Browse the repository at this point in the history
Two tests were failing:
```
FAILED edtf/parser/tests.py::test_edtf_examples[[1667, 1668, 1670..1672]-expected_tuple62] - AttributeError: 'list' object has no attribute 'expandtabs'
FAILED edtf/parser/tests.py::test_edtf_examples[{1667,1668, 1670..1672}-expected_tuple67] - AttributeError: 'list' object has no attribute 'expandtabs'
```

pyparsing.parse_string() was being passed a list by year somehow. Added year_basic for this use case (4 digit year without significant digits). If we need to support Consecutives with significant digits then this isn't a sufficient workaround.
  • Loading branch information
ColeDCrawford committed May 24, 2024
1 parent 7545b6a commit 6b3a9d4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion edtf/parser/grammar.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
negativeYear = NotAny(L("-0000")) + ("-" + positiveYear)

year = Combine(positiveYear ^ negativeYear)("year") + Optional(significantDigits)
# simple version for Consecutives
year_basic = Combine(positiveYear ^ negativeYear)("year")

yearMonth = year + "-" + month
yearMonthDay = year + "-" + monthDay # o hai iso date
Expand Down Expand Up @@ -271,7 +273,9 @@ def f(toks):
consecutives = (
(yearMonthDay("lower") + ".." + yearMonthDay("upper"))
^ (yearMonth("lower") + ".." + yearMonth("upper"))
^ (year("lower") + ".." + year("upper"))
^ (
year_basic("lower") + ".." + year_basic("upper")
) # using year_basic because some tests were throwing `'list' object has no attribute 'expandtabs'` - somewhere, pyparsing.parse_string() was being passed a list
)
Consecutives.set_parser(consecutives)

Expand Down

0 comments on commit 6b3a9d4

Please sign in to comment.