Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/pendulum/formatting/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,7 @@ def parse(
"""
escaped_fmt = re.escape(fmt)

tokens = self._FROM_FORMAT_RE.findall(escaped_fmt)
if not tokens:
if not self._FROM_FORMAT_RE.search(escaped_fmt):
raise ValueError("The given time string does not match the given format")

if not locale:
Expand Down Expand Up @@ -406,7 +405,7 @@ def parse(
lambda m: self._replace_tokens(m.group(0), loaded_locale), escaped_fmt
)

if not re.search("^" + pattern + "$", time):
if not re.fullmatch(pattern, time):
raise ValueError(f"String does not match format {fmt}")

def _get_parsed_values(m: Match[str]) -> Any:
Expand Down
2 changes: 1 addition & 1 deletion src/pendulum/locales/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def load(cls, locale: str | Locale) -> Locale:

@classmethod
def normalize_locale(cls, locale: str) -> str:
m = re.match("([a-z]{2})[-_]([a-z]{2})", locale, re.I)
m = re.fullmatch("([a-z]{2})[-_]([a-z]{2})", locale, re.I)
if m:
return f"{m.group(1).lower()}_{m.group(2).lower()}"
else:
Expand Down
2 changes: 1 addition & 1 deletion src/pendulum/parsing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _parse_common(text: str, **options: Any) -> datetime | date | time:

:param text: The string to parse.
"""
m = COMMON.match(text)
m = COMMON.fullmatch(text)
has_date = False
year = 0
month = 1
Expand Down
4 changes: 2 additions & 2 deletions src/pendulum/parsing/iso8601.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def parse_iso8601(
if parsed is not None:
return parsed

m = ISO8601_DT.match(text)
m = ISO8601_DT.fullmatch(text)
if not m:
raise ParserError("Invalid ISO 8601 string")

Expand Down Expand Up @@ -264,7 +264,7 @@ def parse_iso8601(


def _parse_iso8601_duration(text: str, **options: str) -> Duration | None:
m = ISO8601_DURATION.match(text)
m = ISO8601_DURATION.fullmatch(text)
if not m:
return None

Expand Down