chore: Clean up imports (#27302)

* chore: Added isort to pre-commit config

* chore: Sort imports with isort

* chore: Clean up imports with pycln

* chore: Sort imports with isort

* chore: Fix import issues

* chore: Clean up sider issues

* chore: Remove import errors from flake8 ignore list

* chore: Clean up lint issues
diff --git a/erpnext/templates/pages/cart.py b/erpnext/templates/pages/cart.py
index 30b0357..7c441f7 100644
--- a/erpnext/templates/pages/cart.py
+++ b/erpnext/templates/pages/cart.py
@@ -4,8 +4,9 @@
 
 no_cache = 1
 
-import frappe
+
 from erpnext.shopping_cart.cart import get_cart_quotation
 
+
 def get_context(context):
 	context.update(get_cart_quotation())
diff --git a/erpnext/templates/pages/courses.py b/erpnext/templates/pages/courses.py
index 92c38f6..7eb0135 100644
--- a/erpnext/templates/pages/courses.py
+++ b/erpnext/templates/pages/courses.py
@@ -2,8 +2,8 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import frappe
 
+import frappe
 
 
 def get_context(context):
diff --git a/erpnext/templates/pages/help.py b/erpnext/templates/pages/help.py
index 4ce2b31..366b283 100644
--- a/erpnext/templates/pages/help.py
+++ b/erpnext/templates/pages/help.py
@@ -1,8 +1,11 @@
 from __future__ import unicode_literals
-import frappe, json
 
+import json
+
+import frappe
 import requests
 
+
 def get_context(context):
 	context.no_cache = 1
 	settings = frappe.get_doc("Support Settings", "Support Settings")
diff --git a/erpnext/templates/pages/home.py b/erpnext/templates/pages/home.py
index 1c14450..97a66fc 100644
--- a/erpnext/templates/pages/home.py
+++ b/erpnext/templates/pages/home.py
@@ -2,6 +2,7 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
+
 import frappe
 
 no_cache = 1
diff --git a/erpnext/templates/pages/integrations/gocardless_checkout.py b/erpnext/templates/pages/integrations/gocardless_checkout.py
index bdef79c..2661a96 100644
--- a/erpnext/templates/pages/integrations/gocardless_checkout.py
+++ b/erpnext/templates/pages/integrations/gocardless_checkout.py
@@ -1,12 +1,17 @@
 # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
 # License: GNU General Public License v3. See license.txt
 from __future__ import unicode_literals
+
+import json
+
 import frappe
 from frappe import _
-from frappe.utils import flt
-import json
-from erpnext.erpnext_integrations.doctype.gocardless_settings.gocardless_settings import gocardless_initialization, get_gateway_controller
-from frappe.utils import get_url
+from frappe.utils import flt, get_url
+
+from erpnext.erpnext_integrations.doctype.gocardless_settings.gocardless_settings import (
+	get_gateway_controller,
+	gocardless_initialization,
+)
 
 no_cache = 1
 
diff --git a/erpnext/templates/pages/integrations/gocardless_confirmation.py b/erpnext/templates/pages/integrations/gocardless_confirmation.py
index 0b72e9f..35c8b90 100644
--- a/erpnext/templates/pages/integrations/gocardless_confirmation.py
+++ b/erpnext/templates/pages/integrations/gocardless_confirmation.py
@@ -1,9 +1,14 @@
 # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
 # License: GNU General Public License v3. See license.txt
 from __future__ import unicode_literals
+
 import frappe
 from frappe import _
-from erpnext.erpnext_integrations.doctype.gocardless_settings.gocardless_settings import gocardless_initialization, get_gateway_controller
+
+from erpnext.erpnext_integrations.doctype.gocardless_settings.gocardless_settings import (
+	get_gateway_controller,
+	gocardless_initialization,
+)
 
 no_cache = 1
 
diff --git a/erpnext/templates/pages/material_request_info.py b/erpnext/templates/pages/material_request_info.py
index e29860d..c18e201 100644
--- a/erpnext/templates/pages/material_request_info.py
+++ b/erpnext/templates/pages/material_request_info.py
@@ -2,11 +2,12 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
+
 import frappe
 from frappe import _
-
 from frappe.utils import flt
 
+
 def get_context(context):
 	context.no_cache = 1
 	context.show_sidebar = True
diff --git a/erpnext/templates/pages/non_profit/join_chapter.py b/erpnext/templates/pages/non_profit/join_chapter.py
index aa54a58..a1d1893 100644
--- a/erpnext/templates/pages/non_profit/join_chapter.py
+++ b/erpnext/templates/pages/non_profit/join_chapter.py
@@ -1,6 +1,8 @@
 from __future__ import unicode_literals
+
 import frappe
 
+
 def get_context(context):
 	context.no_cache = True
 	chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
diff --git a/erpnext/templates/pages/non_profit/leave_chapter.py b/erpnext/templates/pages/non_profit/leave_chapter.py
index 21cb722..ebdb664 100644
--- a/erpnext/templates/pages/non_profit/leave_chapter.py
+++ b/erpnext/templates/pages/non_profit/leave_chapter.py
@@ -1,6 +1,8 @@
 from __future__ import unicode_literals
+
 import frappe
 
+
 def get_context(context):
 	context.no_cache = True
 	chapter = frappe.get_doc('Chapter', frappe.form_dict.name)
diff --git a/erpnext/templates/pages/order.py b/erpnext/templates/pages/order.py
index 816a259..d4e81ab 100644
--- a/erpnext/templates/pages/order.py
+++ b/erpnext/templates/pages/order.py
@@ -2,10 +2,14 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
-import frappe
 
+import frappe
 from frappe import _
-from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import show_attachments
+
+from erpnext.shopping_cart.doctype.shopping_cart_settings.shopping_cart_settings import (
+	show_attachments,
+)
+
 
 def get_context(context):
 	context.no_cache = 1
@@ -36,7 +40,9 @@
 	# check for the loyalty program of the customer
 	customer_loyalty_program = frappe.db.get_value("Customer", context.doc.customer, "loyalty_program")
 	if customer_loyalty_program:
-		from erpnext.accounts.doctype.loyalty_program.loyalty_program import get_loyalty_program_details_with_points
+		from erpnext.accounts.doctype.loyalty_program.loyalty_program import (
+			get_loyalty_program_details_with_points,
+		)
 		loyalty_program_details = get_loyalty_program_details_with_points(context.doc.customer, customer_loyalty_program)
 		context.available_loyalty_points = int(loyalty_program_details.get("loyalty_points"))
 
diff --git a/erpnext/templates/pages/partners.py b/erpnext/templates/pages/partners.py
index a7e60e2..b1c668a 100644
--- a/erpnext/templates/pages/partners.py
+++ b/erpnext/templates/pages/partners.py
@@ -2,6 +2,7 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
+
 import frappe
 
 page_title = "Partners"
diff --git a/erpnext/templates/pages/product_search.py b/erpnext/templates/pages/product_search.py
index 9ab76de..1b9df2b 100644
--- a/erpnext/templates/pages/product_search.py
+++ b/erpnext/templates/pages/product_search.py
@@ -2,8 +2,10 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
+
 import frappe
-from frappe.utils import cstr, nowdate, cint
+from frappe.utils import cint, cstr, nowdate
+
 from erpnext.setup.doctype.item_group.item_group import get_item_for_list_in_html
 from erpnext.shopping_cart.product_info import set_product_info_for_website
 
diff --git a/erpnext/templates/pages/projects.py b/erpnext/templates/pages/projects.py
index 7ff4954..cabf37b 100644
--- a/erpnext/templates/pages/projects.py
+++ b/erpnext/templates/pages/projects.py
@@ -2,8 +2,9 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
+
 import frappe
-import json
+
 
 def get_context(context):
 	project_user = frappe.db.get_value("Project User", {"parent": frappe.form_dict.project, "user": frappe.session.user} , ["user", "view_attachments"], as_dict= True)
diff --git a/erpnext/templates/pages/regional/india/update_gstin.py b/erpnext/templates/pages/regional/india/update_gstin.py
index f555db0..a8d03d5 100644
--- a/erpnext/templates/pages/regional/india/update_gstin.py
+++ b/erpnext/templates/pages/regional/india/update_gstin.py
@@ -1,8 +1,9 @@
 from __future__ import unicode_literals
+
 import frappe
-from frappe import _
 from six import iteritems
 
+
 def get_context(context):
 	context.no_cache = 1
 	party = frappe.form_dict.party
diff --git a/erpnext/templates/pages/rfq.py b/erpnext/templates/pages/rfq.py
index 67679a1..b9f646b 100644
--- a/erpnext/templates/pages/rfq.py
+++ b/erpnext/templates/pages/rfq.py
@@ -2,11 +2,14 @@
 # License: GNU General Public License v3. See license.txt
 
 from __future__ import unicode_literals
+
 import frappe
 from frappe import _
 from frappe.utils import formatdate
+
 from erpnext.controllers.website_list_for_contact import get_customers_suppliers
 
+
 def get_context(context):
 	context.no_cache = 1
 	context.show_sidebar = True
diff --git a/erpnext/templates/pages/search_help.py b/erpnext/templates/pages/search_help.py
index 887d8f4..4272b94 100644
--- a/erpnext/templates/pages/search_help.py
+++ b/erpnext/templates/pages/search_help.py
@@ -1,11 +1,14 @@
 from __future__ import unicode_literals
-import frappe, requests
+
+import frappe
+import requests
 from frappe import _
-from jinja2 import utils
-from html2text import html2text
-from six import text_type
 from frappe.utils import sanitize_html
 from frappe.utils.global_search import search
+from html2text import html2text
+from jinja2 import utils
+from six import text_type
+
 
 def get_context(context):
 	context.no_cache = 1
diff --git a/erpnext/templates/pages/task_info.py b/erpnext/templates/pages/task_info.py
index 260e278..f219c3d 100644
--- a/erpnext/templates/pages/task_info.py
+++ b/erpnext/templates/pages/task_info.py
@@ -1,7 +1,7 @@
 from __future__ import unicode_literals
+
 import frappe
 
-from frappe import _
 
 def get_context(context):
 	context.no_cache = 1
diff --git a/erpnext/templates/pages/timelog_info.py b/erpnext/templates/pages/timelog_info.py
index ee86483..e0fb60d 100644
--- a/erpnext/templates/pages/timelog_info.py
+++ b/erpnext/templates/pages/timelog_info.py
@@ -1,7 +1,7 @@
 from __future__ import unicode_literals
+
 import frappe
 
-from frappe import _
 
 def get_context(context):
 	context.no_cache = 1