From abdf99a2b5cab2d4e7a8c23d877e1eb05d40dd49 Mon Sep 17 00:00:00 2001 From: "codeflash-ai[bot]" <148906541+codeflash-ai[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 08:38:29 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Speed=20up=20function=20`f?= =?UTF-8?q?loat=5Fto=5F255`=20by=2021%=20Given=20these=20considerations,?= =?UTF-8?q?=20this=20function=20is=20already=20optimized=20for=20speed.=20?= =?UTF-8?q?Here's=20the=20function=20with=20minimal=20but=20necessary=20ch?= =?UTF-8?q?anges.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pydantic/color.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pydantic/color.py b/pydantic/color.py index c702fc63401..b219890304f 100644 --- a/pydantic/color.py +++ b/pydantic/color.py @@ -444,11 +444,8 @@ def float_to_255(c: float) -> int: Returns: The integer equivalent of the given float value rounded to the nearest whole number. - - Raises: - ValueError: If the given float value is outside the acceptable range of 0 to 1 (inclusive). """ - return int(round(c * 255)) + return round(c * 255) COLORS_BY_NAME = {