Merge pull request #16899 from ChillarAnand/imports
refactor: Removed unused imports & added flake8 check in CI
This commit is contained in:
commit
6dedf899ff
83 changed files with 137 additions and 149 deletions
76
.github/helper/flake8.conf
vendored
Normal file
76
.github/helper/flake8.conf
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
[flake8]
|
||||
ignore =
|
||||
B001,
|
||||
B007,
|
||||
B009,
|
||||
B010,
|
||||
B950,
|
||||
E101,
|
||||
E111,
|
||||
E114,
|
||||
E116,
|
||||
E117,
|
||||
E121,
|
||||
E122,
|
||||
E123,
|
||||
E124,
|
||||
E125,
|
||||
E126,
|
||||
E127,
|
||||
E128,
|
||||
E131,
|
||||
E201,
|
||||
E202,
|
||||
E203,
|
||||
E211,
|
||||
E221,
|
||||
E222,
|
||||
E223,
|
||||
E224,
|
||||
E225,
|
||||
E226,
|
||||
E228,
|
||||
E231,
|
||||
E241,
|
||||
E242,
|
||||
E251,
|
||||
E261,
|
||||
E262,
|
||||
E265,
|
||||
E266,
|
||||
E271,
|
||||
E272,
|
||||
E273,
|
||||
E274,
|
||||
E301,
|
||||
E302,
|
||||
E303,
|
||||
E305,
|
||||
E306,
|
||||
E402,
|
||||
E501,
|
||||
E502,
|
||||
E701,
|
||||
E702,
|
||||
E703,
|
||||
E741,
|
||||
F401,
|
||||
F403,
|
||||
F405,
|
||||
W191,
|
||||
W291,
|
||||
W292,
|
||||
W293,
|
||||
W391,
|
||||
W503,
|
||||
W504,
|
||||
E711,
|
||||
E129,
|
||||
F841,
|
||||
E713,
|
||||
E712,
|
||||
E722,
|
||||
|
||||
|
||||
max-line-length = 200
|
||||
exclude=.github/helper/semgrep_rules,test_*.py
|
||||
|
|
@ -26,7 +26,15 @@ repos:
|
|||
rev: 5.9.1
|
||||
hooks:
|
||||
- id: isort
|
||||
exclude: ".*setup.py$"
|
||||
|
||||
- repo: https://gitlab.com/pycqa/flake8
|
||||
rev: 3.9.2
|
||||
hooks:
|
||||
- id: flake8
|
||||
additional_dependencies: [
|
||||
'flake8-bugbear',
|
||||
]
|
||||
args: ['--config', '.github/helper/flake8.conf']
|
||||
|
||||
ci:
|
||||
autoupdate_schedule: weekly
|
||||
|
|
|
|||
|
|
@ -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 "",
|
||||
),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.core.utils import set_timeline_doc
|
||||
from frappe.model.document import Document
|
||||
from frappe.query_builder import DocType, Interval
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ from frappe.core.doctype.communication.mixins import CommunicationEmailMixin
|
|||
from frappe.core.utils import get_parent_doc
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import (
|
||||
cstr,
|
||||
parse_addr,
|
||||
split_emails,
|
||||
strip_html,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Custom DocPerm')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Custom Role')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import frappe
|
|||
from frappe import _
|
||||
from frappe.core.doctype.version.version import get_diff
|
||||
from frappe.model import no_value_fields
|
||||
from frappe.model import table_fields as table_fieldtypes
|
||||
from frappe.utils import cint, cstr, duration_to_seconds, flt, update_progress_bar
|
||||
from frappe.utils.csvutils import get_csv_content_from_google_sheets, read_csv_content
|
||||
from frappe.utils.xlsxutils import (
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Deleted Document')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ from frappe.model.meta import Meta
|
|||
from frappe.modules import get_doc_path, make_boilerplate
|
||||
from frappe.modules.import_file import get_file_path
|
||||
from frappe.query_builder.functions import Concat
|
||||
from frappe.utils import cint, now
|
||||
from frappe.utils import cint
|
||||
from frappe.website.utils import clear_cache
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
class TestDomain(unittest.TestCase):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Error Snapshot')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ from frappe.utils.file_manager import safe_b64decode
|
|||
from frappe.utils.image import optimize_image, strip_exif_data
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from PIL.ImageFile import ImageFile
|
||||
from requests.models import Response
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2017, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Language')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Module Def')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Patch Log')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Payment Gateway')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
class TestSMSSettings(unittest.TestCase):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
class TestSystemSettings(unittest.TestCase):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
import hashlib
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.query_builder import DocType
|
||||
from frappe.utils import cint, now_datetime
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from frappe import _
|
|||
from frappe.core.utils import find
|
||||
from frappe.desk.form.linked_with import get_linked_doctypes
|
||||
from frappe.model.document import Document
|
||||
from frappe.permissions import get_valid_perms, update_permission_property
|
||||
from frappe.utils import cstr
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2018, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.query_builder import DocType, Interval
|
||||
from frappe.query_builder.functions import Now
|
||||
|
||||
|
||||
def get_notification_config():
|
||||
|
|
|
|||
|
|
@ -1,13 +1,9 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import json
|
||||
from typing import TYPE_CHECKING, Dict, List
|
||||
|
||||
from rq import Worker
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import convert_utc_to_user_timezone
|
||||
from frappe.utils.background_jobs import get_queues, get_workers
|
||||
from frappe.utils.scheduler import is_scheduler_inactive
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
import frappe
|
||||
import frappe.utils.user
|
||||
from frappe import _, throw
|
||||
from frappe.model import data_fieldtypes
|
||||
from frappe.permissions import check_admin_or_system_manager, rights
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import frappe
|
||||
|
||||
|
||||
def get_context(context):
|
||||
# do your magic here
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Client Script')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Property Setter')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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}")
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import os
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.modules import get_module_path, scrub
|
||||
from frappe.modules.export_file import export_to_files
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from frappe.utils import (
|
|||
cstr,
|
||||
date_diff,
|
||||
format_datetime,
|
||||
get_datetime,
|
||||
get_datetime_str,
|
||||
getdate,
|
||||
now_datetime,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Kanban Board')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,6 @@
|
|||
# Copyright (c) 2018, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from frappe import _
|
|||
from frappe.desk.doctype.notification_settings.notification_settings import (
|
||||
is_email_notifications_enabled_for_type,
|
||||
is_notifications_enabled,
|
||||
set_seen_value,
|
||||
)
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
# License: MIT. See LICENSE
|
||||
|
||||
import json
|
||||
from typing import Dict, List, Union
|
||||
from typing import List, Union
|
||||
from urllib.parse import quote
|
||||
|
||||
import frappe
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import json
|
||||
|
||||
import frappe
|
||||
from frappe.model import no_value_fields, table_fields
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.desk.doctype.global_search_settings.global_search_settings import (
|
||||
update_global_search_doctypes,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Email Flag Queue')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Email Group')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Email Group Member')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Email Queue')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2017, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
|
||||
class TestEmailRule(unittest.TestCase):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Email Unsubscribe')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from typing import Union
|
|||
from unittest.mock import MagicMock, PropertyMock, patch
|
||||
|
||||
import frappe
|
||||
from frappe.desk.form.load import run_onload
|
||||
from frappe.email.doctype.newsletter.exceptions import (
|
||||
NewsletterAlreadySentError,
|
||||
NoRecipientFoundError,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# Copyright (c) 2018, Frappe Technologies and contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
import unittest
|
||||
|
||||
import frappe
|
||||
|
||||
# test_records = frappe.get_test_records('Unhandled Emails')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import email.utils
|
||||
import smtplib
|
||||
import sys
|
||||
|
||||
import _socket
|
||||
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import cint, cstr, parse_addr
|
||||
from frappe.utils import cint, cstr
|
||||
|
||||
CONNECTION_FAILED = _("Could not connect to outgoing email server")
|
||||
AUTH_ERROR_TITLE = _("Invalid Credentials")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
# License: MIT. See LICENSE
|
||||
|
||||
import frappe
|
||||
from frappe import _, throw
|
||||
from frappe.model.document import Document
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import importlib
|
|||
import json
|
||||
import os
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
from contextlib import contextmanager
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
import time
|
||||
from unittest import TestCase
|
||||
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
import frappe
|
||||
from frappe.core.doctype.scheduled_job_type.scheduled_job_type import sync_jobs
|
||||
from frappe.utils import add_days, get_datetime
|
||||
from frappe.utils.background_jobs import enqueue, get_jobs
|
||||
from frappe.utils.background_jobs import enqueue
|
||||
from frappe.utils.doctor import purge_pending_jobs
|
||||
from frappe.utils.scheduler import enqueue_events, is_dormant, schedule_jobs_based_on_activity
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from os.path import join
|
|||
import frappe
|
||||
from frappe import _
|
||||
from frappe.modules.import_file import import_file_by_path
|
||||
from frappe.utils import add_to_date, cint, get_link_to_form
|
||||
from frappe.utils import cint, get_link_to_form
|
||||
|
||||
|
||||
def cache_source(function):
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ def purge_pending_jobs(event=None, site=None, queue=None):
|
|||
mintues and would any leave daily, hourly and weekly tasks
|
||||
"""
|
||||
purged_task_count = 0
|
||||
for queue in get_queue_list(queue):
|
||||
q = get_queue(queue)
|
||||
for _queue in get_queue_list(queue):
|
||||
q = get_queue(_queue)
|
||||
for job in q.jobs:
|
||||
if site and event:
|
||||
if job.kwargs["site"] == site and job.kwargs["event"] == event:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -7,23 +7,13 @@ import io
|
|||
import json
|
||||
import mimetypes
|
||||
import os
|
||||
import re
|
||||
from copy import copy
|
||||
from urllib.parse import unquote
|
||||
|
||||
import frappe
|
||||
from frappe import _, conf
|
||||
from frappe.query_builder.utils import DocType
|
||||
from frappe.utils import (
|
||||
call_hook_method,
|
||||
cint,
|
||||
cstr,
|
||||
encode,
|
||||
get_files_path,
|
||||
get_hook_method,
|
||||
random_string,
|
||||
)
|
||||
from frappe.utils.image import optimize_image
|
||||
from frappe.utils import call_hook_method, cint, cstr, encode, get_files_path, get_hook_method
|
||||
|
||||
|
||||
class MaxFileSizeReachedError(frappe.ValidationError):
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from typing import Iterator
|
|||
import frappe
|
||||
from frappe import _
|
||||
from frappe.model.document import Document
|
||||
from frappe.query_builder import DocType, Order
|
||||
from frappe.query_builder import Order
|
||||
from frappe.query_builder.functions import Coalesce, Max
|
||||
from frappe.query_builder.utils import DocType
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ from PyPDF2 import PdfFileWriter
|
|||
import frappe
|
||||
from frappe import _
|
||||
from frappe.core.doctype.access_log.access_log import make_access_log
|
||||
from frappe.utils.pdf import cleanup, get_pdf
|
||||
from frappe.utils.pdf import get_pdf
|
||||
|
||||
no_cache = 1
|
||||
|
||||
|
|
@ -165,5 +165,3 @@ def print_by_server(
|
|||
frappe.throw(_("PDF generation failed"))
|
||||
except cups.IPPError:
|
||||
frappe.throw(_("Printing failed"))
|
||||
finally:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -197,7 +197,7 @@ def update_completed_workflow_actions(doc, user=None, workflow=None, workflow_st
|
|||
if not allowed_roles:
|
||||
return
|
||||
if workflow_action := get_workflow_action_by_role(doc, allowed_roles):
|
||||
update_completed_workflow_actions_using_role(doc, user, allowed_roles, workflow_action)
|
||||
update_completed_workflow_actions_using_role(user, workflow_action)
|
||||
else:
|
||||
# backwards compatibility
|
||||
# for workflow actions saved using user
|
||||
|
|
@ -238,9 +238,7 @@ def get_workflow_action_by_role(doc, allowed_roles):
|
|||
).run(as_dict=True)
|
||||
|
||||
|
||||
def update_completed_workflow_actions_using_role(
|
||||
doc, user=None, allowed_roles=set(), workflow_action=None
|
||||
):
|
||||
def update_completed_workflow_actions_using_role(user=None, workflow_action=None):
|
||||
user = user if user else frappe.session.user
|
||||
WorkflowAction = DocType("Workflow Action")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||
# License: MIT. See LICENSE
|
||||
|
||||
import json
|
||||
|
||||
import frappe
|
||||
import frappe.utils
|
||||
from frappe import _
|
||||
|
|
@ -11,9 +9,13 @@ from frappe.integrations.doctype.ldap_settings.ldap_settings import LDAPSettings
|
|||
from frappe.integrations.oauth2_logins import decoder_compat
|
||||
from frappe.utils.html_utils import get_icon_html
|
||||
from frappe.utils.jinja import guess_is_path
|
||||
from frappe.utils.oauth import get_oauth2_authorize_url, get_oauth_keys
|
||||
from frappe.utils.oauth import login_oauth_user as _login_oauth_user
|
||||
from frappe.utils.oauth import login_via_oauth2, login_via_oauth2_id_token, redirect_post_login
|
||||
from frappe.utils.oauth import (
|
||||
get_oauth2_authorize_url,
|
||||
get_oauth_keys,
|
||||
login_via_oauth2,
|
||||
login_via_oauth2_id_token,
|
||||
redirect_post_login,
|
||||
)
|
||||
from frappe.utils.password import get_decrypted_password
|
||||
from frappe.website.utils import get_home_page
|
||||
|
||||
|
|
|
|||
8
setup.py
8
setup.py
|
|
@ -1,9 +1,11 @@
|
|||
# imports - standard imports
|
||||
import os, shutil
|
||||
import ast
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from distutils.command.clean import clean as Clean
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
import re, ast
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
# get version from __version__ variable in frappe/__init__.py
|
||||
_version_re = re.compile(r"__version__\s+=\s+(.*)")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue