fix: ruff manual fixes

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-12-22 17:27:06 +05:30
parent f7feeea0a0
commit 90a40dbfe0
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
3 changed files with 2 additions and 45 deletions

View file

@ -432,7 +432,7 @@ def after_request(*args, **kwargs):
_test_REQ_HOOK["after_request"] = time()
class TestResponse(FrappeAPITestCase):
class TestAPIResponse(FrappeAPITestCase):
def test_generate_pdf(self):
response = self.get(
"/api/method/frappe.utils.print_format.download_pdf",

View file

@ -249,7 +249,7 @@ class TestPerformance(IntegrationTestCase):
default_affinity_16 = list(range(16))
# "linear" siblings = (0,1) (2,3) ...
linear_siblings_16 = list(itertools.batched(range(16), 2))
linear_siblings_16 = list(itertools.batched(range(16), 2, strict=True))
logical_cores = list(range(16))
expected_assignments = [*(l[0] for l in linear_siblings_16), *(l[1] for l in linear_siblings_16)]
for pid, expected_core in zip(logical_cores, expected_assignments, strict=True):

View file

@ -49,8 +49,6 @@ UNSET = object()
type PropertyType = property | functools.cached_property
def get_fullname(user=None):
"""get the full name (first name + last name) of the user from User"""
if not user:
@ -1191,44 +1189,3 @@ def create_folder(path, with_init=False):
cached_property = functools.cached_property
if sys.version_info.minor < 12:
T = TypeVar("T")
class cached_property(functools.cached_property, Generic[T]):
"""
A simpler `functools.cached_property` implementation without locks.
This isn't needed in Python 3.12+, since lock was removed in newer versions.
Hence, in those versions, it returns the `functools.cached_property` object.
This does not prevent a possible race condition in multi-threaded usage.
The getter function could run more than once on the same instance,
with the latest run setting the cached value. If the cached property is
idempotent or otherwise not harmful to run more than once on an instance,
this is fine. If synchronization is needed, implement the necessary locking
inside the decorated getter function or around the cached property access.
"""
def __init__(self, func: Callable[[Any], T]):
self.func = func
self.attrname = None
self.__doc__ = func.__doc__
self.__module__ = func.__module__
def __set_name__(self, owner, name):
if self.attrname is None:
self.attrname = name
elif name != self.attrname:
raise TypeError(
"Cannot assign the same cached_property to two different names "
f"({self.attrname!r} and {name!r})."
)
def __get__(self, instance, owner=None) -> T:
if instance is None:
return self
value = self.func(instance)
instance.__dict__[self.attrname] = value
return value
# end: custom cached_property implementation