Enable flake8-annotations linting rules (#267)
See https://docs.astral.sh/ruff/rules/#flake8-annotations-ann.
This commit is contained in:
@@ -2,25 +2,25 @@ import calendar
|
||||
from datetime import datetime, timezone
|
||||
|
||||
|
||||
def parse_date(text, formats=frozenset([
|
||||
"%B %d %Y", # January 1 2020
|
||||
"%b %d %Y", # Jan 1 2020
|
||||
"%d %B %Y", # 1 January 2020
|
||||
"%d %b %Y", # 1 Jan 2020
|
||||
"%d-%b-%Y", # 1-Jan-2020
|
||||
"%d-%B-%Y", # 1-January-2020
|
||||
"%Y-%m-%d", # 2020-01-01
|
||||
"%m/%d/%Y", # 01/25/2020
|
||||
def parse_date(text: str, formats: list[str] = frozenset([
|
||||
"%B %d %Y", # January 1 2020
|
||||
"%b %d %Y", # Jan 1 2020
|
||||
"%d %B %Y", # 1 January 2020
|
||||
"%d %b %Y", # 1 Jan 2020
|
||||
"%d-%b-%Y", # 1-Jan-2020
|
||||
"%d-%B-%Y", # 1-January-2020
|
||||
"%Y-%m-%d", # 2020-01-01
|
||||
"%m/%d/%Y", # 01/25/2020
|
||||
])) -> datetime:
|
||||
"""Parse a given text representing a date using a list of formats.
|
||||
"""
|
||||
return parse_datetime(text, formats, to_utc=False)
|
||||
|
||||
|
||||
def parse_month_year_date(text, formats=frozenset([
|
||||
"%B %Y", # January 2020
|
||||
"%b %Y", # Jan 2020
|
||||
])) -> datetime:
|
||||
def parse_month_year_date(text: str, formats: list[str] = frozenset([
|
||||
"%B %Y", # January 2020
|
||||
"%b %Y", # Jan 2020
|
||||
])) -> datetime:
|
||||
"""Parse a given text representing a partial date using a list of formats,
|
||||
adjusting it to the last day of the month.
|
||||
"""
|
||||
@@ -29,14 +29,14 @@ def parse_month_year_date(text, formats=frozenset([
|
||||
return date.replace(day=last_day)
|
||||
|
||||
|
||||
def parse_datetime(text, formats=frozenset([
|
||||
def parse_datetime(text: str, formats: list[str] = frozenset([
|
||||
"%Y-%m-%d %H:%M:%S", # 2023-05-01 08:32:34
|
||||
"%Y-%m-%dT%H:%M:%S", # 2023-05-01T08:32:34
|
||||
"%Y-%m-%d %H:%M:%S %z", # 2023-05-01 08:32:34 +0900
|
||||
"%Y-%m-%dT%H:%M:%S%z", # 2023-05-01T08:32:34+0900
|
||||
"%Y-%m-%dT%H:%M:%S.%f%z", # 2023-05-01T08:32:34.123456Z
|
||||
"%a %d %b %Y %H:%M:%S %Z", # Wed, 01 Jan 2020 00:00:00 GMT
|
||||
]), to_utc=True) -> datetime:
|
||||
]), to_utc: bool = True) -> datetime:
|
||||
"""Parse a given text representing a datetime using a list of formats,
|
||||
optionally converting it to UTC.
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user