Skip to content

Commit

Permalink
fix: None in try_date_expr() (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar authored Oct 4, 2023
1 parent 47fbb1c commit 5b6cea8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion htmldate/extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,16 @@ def external_date_parser(string: str, outputformat: str) -> Optional[str]:

@lru_cache(maxsize=CACHE_SIZE)
def try_date_expr(
string: str,
string: Optional[str],
outputformat: str,
extensive_search: bool,
min_date: datetime,
max_date: datetime,
) -> Optional[str]:
"""Use a series of heuristics and rules to parse a potential date expression"""
if not string:
return None

# trim
string = " ".join(string.strip()[:MAX_TEXT_SIZE].split())

Expand Down
3 changes: 3 additions & 0 deletions tests/unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,16 @@ def test_convert_date():

def test_try_date_expr():
"""test date extraction via external package"""
assert try_date_expr(None, OUTPUTFORMAT, False, MIN_DATE, LATEST_POSSIBLE) is None

find_date.extensive_search = False
assert (
try_date_expr(
"Fri, Sept 1, 2017", OUTPUTFORMAT, False, MIN_DATE, LATEST_POSSIBLE
)
is None
)

find_date.extensive_search = True
assert (
try_date_expr(
Expand Down

0 comments on commit 5b6cea8

Please sign in to comment.