refactor: Fix flake8 issues
This commit is contained in:
parent
e2652daf73
commit
1d763a6659
13 changed files with 28 additions and 25 deletions
|
|
@ -268,7 +268,6 @@ def address_query(doctype, txt, searchfield, start, page_len, filters):
|
|||
`tabAddress`.idx desc, `tabAddress`.name
|
||||
limit %(start)s, %(page_len)s """.format(
|
||||
mcond=get_match_cond(doctype),
|
||||
key=searchfield,
|
||||
search_condition=search_condition,
|
||||
condition=condition or "",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -524,7 +524,10 @@ class CustomizeForm(Document):
|
|||
"""allow type change, if both old_type and new_type are in same field group.
|
||||
field groups are defined in ALLOWED_FIELDTYPE_CHANGE variables.
|
||||
"""
|
||||
in_field_group = lambda group: (old_type in group) and (new_type in group)
|
||||
|
||||
def in_field_group(group):
|
||||
return (old_type in group) and (new_type in group)
|
||||
|
||||
return any(map(in_field_group, ALLOWED_FIELDTYPE_CHANGE))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def drop_user_and_database(db_name, root_login, root_password):
|
|||
)
|
||||
root_conn.commit()
|
||||
root_conn.sql(
|
||||
f"SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = %s",
|
||||
"SELECT pg_terminate_backend (pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = %s",
|
||||
(db_name,),
|
||||
)
|
||||
root_conn.sql(f"DROP DATABASE IF EXISTS {db_name}")
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ def confirmed_unsubscribe(email, group):
|
|||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def subscribe(email, email_group=_("Website")):
|
||||
def subscribe(email, email_group=_("Website")): # noqa
|
||||
"""API endpoint to subscribe an email to a particular email group. Triggers a confirmation email."""
|
||||
|
||||
# build subscription confirmation URL
|
||||
|
|
@ -282,7 +282,7 @@ def subscribe(email, email_group=_("Website")):
|
|||
|
||||
|
||||
@frappe.whitelist(allow_guest=True)
|
||||
def confirm_subscription(email, email_group=_("Website")):
|
||||
def confirm_subscription(email, email_group=_("Website")): # noqa
|
||||
"""API endpoint to confirm email subscription.
|
||||
This endpoint is called when user clicks on the link sent to their mail.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -982,11 +982,11 @@ def is_parent_only_filter(doctype, filters):
|
|||
only_parent_doctype = True
|
||||
|
||||
if isinstance(filters, list):
|
||||
for flt in filters:
|
||||
if doctype not in flt:
|
||||
for filter in filters:
|
||||
if doctype not in filter:
|
||||
only_parent_doctype = False
|
||||
if "Between" in flt:
|
||||
flt[3] = get_between_date_filter(flt[3])
|
||||
if "Between" in filter:
|
||||
filter[3] = get_between_date_filter(flt[3])
|
||||
|
||||
return only_parent_doctype
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ def delete_doc(
|
|||
):
|
||||
try:
|
||||
delete_controllers(name, doc.module)
|
||||
except (FileNotFoundError, OSError, KeyError):
|
||||
except (OSError, KeyError):
|
||||
# in case a doctype doesnt have any controller code nor any app and module
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -774,7 +774,10 @@ def trim_table(doctype, dry_run=True):
|
|||
ignore_fields = default_fields + optional_fields + child_table_fields
|
||||
columns = frappe.db.get_table_columns(doctype)
|
||||
fields = frappe.get_meta(doctype, cached=False).get_fieldnames_with_value()
|
||||
is_internal = lambda f: f not in ignore_fields and not f.startswith("_")
|
||||
|
||||
def is_internal(field):
|
||||
return field not in ignore_fields and not field.startswith("_")
|
||||
|
||||
columns_to_remove = [f for f in list(set(columns) - set(fields)) if is_internal(f)]
|
||||
DROPPED_COLUMNS = columns_to_remove[:]
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ def execute():
|
|||
name, script = server_script["name"], server_script["script"]
|
||||
|
||||
for agg in ["avg", "max", "min", "sum"]:
|
||||
script = re.sub(f"frappe.db.{agg}\(", f"frappe.qb.{agg}(", script)
|
||||
script = re.sub(f"frappe.db.{agg}\\(", f"frappe.qb.{agg}(", script)
|
||||
|
||||
frappe.db.update("Server Script", name, "script", script)
|
||||
|
|
|
|||
|
|
@ -227,8 +227,8 @@ def get_jobs(site=None, queue=None, key="method"):
|
|||
# optional keyword arguments are stored in 'kwargs' of 'kwargs'
|
||||
jobs_per_site[job.kwargs["site"]].append(job.kwargs["kwargs"][key])
|
||||
|
||||
for queue in get_queue_list(queue):
|
||||
q = get_queue(queue)
|
||||
for _queue in get_queue_list(queue):
|
||||
q = get_queue(_queue)
|
||||
jobs = q.jobs + get_running_jobs_in_queue(q)
|
||||
for job in jobs:
|
||||
if job.kwargs.get("site"):
|
||||
|
|
|
|||
|
|
@ -654,14 +654,14 @@ class Backup:
|
|||
print("Invalid path", self.file_path)
|
||||
return
|
||||
else:
|
||||
os.rename(self.file_path, self.file_path + ".gpg")
|
||||
file_path = self.file_path + ".gpg"
|
||||
file_path_with_ext = self.file_path + ".gpg"
|
||||
os.rename(self.file_path, file_path_with_ext)
|
||||
|
||||
cmd_string = "gpg --yes --passphrase {passphrase} --pinentry-mode loopback -o {decrypted_file} -d {file_location}"
|
||||
command = cmd_string.format(
|
||||
passphrase=passphrase,
|
||||
file_location=file_path,
|
||||
decrypted_file=file_path.rstrip(".gpg"),
|
||||
file_location=file_path_with_ext,
|
||||
decrypted_file=self.file_path,
|
||||
)
|
||||
frappe.utils.execute_in_shell(command)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ def get_snapshot(exception, context=10):
|
|||
# basic frame information
|
||||
f = {"file": file, "func": func, "call": call, "lines": {}, "lnum": lnum}
|
||||
|
||||
def reader(lnum=[lnum]):
|
||||
def reader(lnum=[lnum]): # noqa
|
||||
try:
|
||||
return linecache.getline(file, lnum[0])
|
||||
finally:
|
||||
|
|
|
|||
|
|
@ -447,13 +447,13 @@ def search(text, start=0, limit=20, doctype=""):
|
|||
|
||||
allowed_doctypes = get_doctypes_for_global_search()
|
||||
|
||||
for text in set(text.split("&")):
|
||||
text = text.strip()
|
||||
if not text:
|
||||
for word in set(text.split("&")):
|
||||
word = word.strip()
|
||||
if not word:
|
||||
continue
|
||||
|
||||
global_search = frappe.qb.Table("__global_search")
|
||||
rank = Match(global_search.content).Against(text).as_("rank")
|
||||
rank = Match(global_search.content).Against(word).as_("rank")
|
||||
query = (
|
||||
frappe.qb.from_(global_search)
|
||||
.select(global_search.doctype, global_search.name, global_search.content, rank)
|
||||
|
|
|
|||
|
|
@ -165,5 +165,3 @@ def print_by_server(
|
|||
frappe.throw(_("PDF generation failed"))
|
||||
except cups.IPPError:
|
||||
frappe.throw(_("Printing failed"))
|
||||
finally:
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue