refactor: Remove unused imports & code

This commit is contained in:
chillaranand 2022-05-16 11:34:53 +05:30
parent 1d763a6659
commit 25f82e966c
69 changed files with 22 additions and 125 deletions

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Custom DocPerm')

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Custom Role')

View file

@ -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 (

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Deleted Document')

View file

@ -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

View file

@ -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

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
class TestDomain(unittest.TestCase):
pass

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Error Snapshot')

View file

@ -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

View file

@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Language')

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Module Def')

View file

@ -3,7 +3,6 @@
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Patch Log')

View file

@ -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

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Payment Gateway')

View file

@ -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

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
class TestSMSSettings(unittest.TestCase):
pass

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
class TestSystemSettings(unittest.TestCase):
pass

View file

@ -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

View file

@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -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

View file

@ -2,7 +2,6 @@
# Copyright (c) 2018, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -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():

View file

@ -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

View file

@ -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

View file

@ -1,6 +1,3 @@
import frappe
def get_context(context):
# do your magic here
pass

View file

@ -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

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Client Script')

View file

@ -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

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Property Setter')

View file

@ -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

View file

@ -18,7 +18,6 @@ from frappe.utils import (
cstr,
date_diff,
format_datetime,
get_datetime,
get_datetime_str,
getdate,
now_datetime,

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Kanban Board')

View file

@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -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

View file

@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -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

View file

@ -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

View file

@ -1,5 +1,3 @@
import json
import frappe
from frappe.model import no_value_fields, table_fields

View file

@ -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,
)

View file

@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Email Flag Queue')

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Email Group')

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Email Group Member')

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Email Queue')

View file

@ -2,7 +2,6 @@
# Copyright (c) 2017, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
class TestEmailRule(unittest.TestCase):
pass

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Email Unsubscribe')

View file

@ -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,

View file

@ -2,7 +2,6 @@
# Copyright (c) 2015, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -2,7 +2,6 @@
# Copyright (c) 2018, Frappe Technologies and contributors
# License: MIT. See LICENSE
import frappe
from frappe.model.document import Document

View file

@ -3,8 +3,6 @@
# License: MIT. See LICENSE
import unittest
import frappe
# test_records = frappe.get_test_records('Unhandled Emails')

View file

@ -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")

View file

@ -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

View file

@ -2,7 +2,6 @@
# License: MIT. See LICENSE
import frappe
from frappe import _, throw
from frappe.model.document import Document

View file

@ -7,7 +7,6 @@ import importlib
import json
import os
import shlex
import shutil
import subprocess
import unittest
from contextlib import contextmanager

View file

@ -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

View file

@ -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):

View file

@ -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:

View file

@ -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):

View file

@ -100,8 +100,6 @@ class Identicon(object):
if format.upper() not in Image.SAVE:
Image.init()
save_handler = Image.SAVE[format.upper()]
try:
save_handler(self.image, fp, "")
finally:
fp.seek(0)
return "data:image/png;base64,{0}".format(base64.b64encode(fp.read()))
save_handler(self.image, fp, "")
fp.seek(0)
return "data:image/png;base64,{0}".format(base64.b64encode(fp.read()))

View file

@ -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

View file

@ -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

View file

@ -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")

View file

@ -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