From 9b0ddc5fc969b8589080aa64053fa2e8a0389e41 Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 03:44:13 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20method=20`Dat?= =?UTF-8?q?eTime.=5Ftry=5Fto=5Fconvert=5Fdate`=20by=20803%=20**Explanation?= =?UTF-8?q?=20of=20changes:**?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/click/types.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/click/types.py b/src/click/types.py index 354c7e381..c7b84c081 100644 --- a/src/click/types.py +++ b/src/click/types.py @@ -15,6 +15,7 @@ from .utils import format_filename from .utils import LazyFile from .utils import safecall +from functools import lru_cache if t.TYPE_CHECKING: import typing_extensions as te @@ -385,6 +386,7 @@ def to_info_dict(self) -> dict[str, t.Any]: def get_metavar(self, param: Parameter) -> str: return f"[{'|'.join(self.formats)}]" + @lru_cache(maxsize=None) def _try_to_convert_date(self, value: t.Any, format: str) -> datetime | None: try: return datetime.strptime(value, format)