fix: wrap read_only functions correctly (#25018)

`functools.wraps` preserves signature useful for introspection.
This commit is contained in:
Ankush Menat 2024-02-22 16:46:15 +05:30 committed by GitHub
parent d8890a2286
commit 1ff7b84140
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View file

@ -941,6 +941,7 @@ def is_whitelisted(method):
def read_only():
def innfn(fn):
@functools.wraps(fn)
def wrapper_fn(*args, **kwargs):
# frappe.read_only could be called from nested functions, in such cases don't swap the
# connection again.

View file

@ -241,7 +241,7 @@ def get_filters_for(doctype):
@frappe.whitelist()
@frappe.read_only()
def get_open_count(doctype, name, items=None):
def get_open_count(doctype: str, name: str, items=None):
"""Get count for internal and external links for given transactions
:param doctype: Reference DocType