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/demo/demo.py b/erpnext/demo/demo.py
index a4e4220..5be2420 100644
--- a/erpnext/demo/demo.py
+++ b/erpnext/demo/demo.py
@@ -1,11 +1,16 @@
from __future__ import unicode_literals
-import frappe, sys
-import erpnext
+import sys
+
+import frappe
import frappe.utils
-from erpnext.demo.user import hr, sales, purchase, manufacturing, stock, accounts, projects, fixed_asset
+
+import erpnext
+from erpnext.demo.setup import education, healthcare, manufacture, retail, setup_data
+from erpnext.demo.user import accounts
from erpnext.demo.user import education as edu
-from erpnext.demo.setup import education, manufacture, setup_data, healthcare, retail
+from erpnext.demo.user import fixed_asset, hr, manufacturing, projects, purchase, sales, stock
+
"""
Make a demo
diff --git a/erpnext/demo/setup/education.py b/erpnext/demo/setup/education.py
index cf9451d..304bc3d 100644
--- a/erpnext/demo/setup/education.py
+++ b/erpnext/demo/setup/education.py
@@ -2,11 +2,15 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import frappe, json
-from frappe.utils.make_random import get_random
-from datetime import datetime
-from erpnext.demo.setup.setup_data import import_json
+import json
import random
+from datetime import datetime
+
+import frappe
+from frappe.utils.make_random import get_random
+
+from erpnext.demo.setup.setup_data import import_json
+
def setup_data():
frappe.flags.mute_emails = True
diff --git a/erpnext/demo/setup/healthcare.py b/erpnext/demo/setup/healthcare.py
index aa389e5..5d5707f 100644
--- a/erpnext/demo/setup/healthcare.py
+++ b/erpnext/demo/setup/healthcare.py
@@ -2,13 +2,17 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
-import frappe, json
-from frappe.utils.make_random import get_random
import datetime
-from erpnext.demo.setup.setup_data import import_json
+import json
+
+import frappe
from frappe.utils import getdate
+from frappe.utils.make_random import get_random
+
+from erpnext.demo.setup.setup_data import import_json
from erpnext.healthcare.doctype.lab_test.lab_test import create_test_from_template
+
def setup_data():
frappe.flags.mute_emails = True
make_masters()
diff --git a/erpnext/demo/setup/manufacture.py b/erpnext/demo/setup/manufacture.py
index 7d6b501..5db3519 100644
--- a/erpnext/demo/setup/manufacture.py
+++ b/erpnext/demo/setup/manufacture.py
@@ -1,13 +1,16 @@
from __future__ import unicode_literals
-import random, json
-import frappe
-from frappe.utils import nowdate, add_days
-from erpnext.demo.setup.setup_data import import_json
-from erpnext.demo.domains import data
+import json
+import random
+import frappe
+from frappe.utils import add_days, nowdate
from six import iteritems
+from erpnext.demo.domains import data
+from erpnext.demo.setup.setup_data import import_json
+
+
def setup_data():
import_json("Location")
import_json("Asset Category")
diff --git a/erpnext/demo/setup/retail.py b/erpnext/demo/setup/retail.py
index 82d1c15..d94d2d6 100644
--- a/erpnext/demo/setup/retail.py
+++ b/erpnext/demo/setup/retail.py
@@ -1,12 +1,12 @@
from __future__ import unicode_literals
-import random, json
+import json
+
import frappe
-from frappe.utils import nowdate, add_days
-from erpnext.demo.setup.setup_data import import_json
+from six import iteritems
+
from erpnext.demo.domains import data
-from six import iteritems
def setup_data():
setup_item()
diff --git a/erpnext/demo/setup/setup_data.py b/erpnext/demo/setup/setup_data.py
index 05ee28a..42f83a3 100644
--- a/erpnext/demo/setup/setup_data.py
+++ b/erpnext/demo/setup/setup_data.py
@@ -1,13 +1,18 @@
from __future__ import print_function, unicode_literals
-import random, json
-import frappe, erpnext
-from frappe.utils.nestedset import get_root_of
-from frappe.utils import flt, now_datetime, cstr, random_string
-from frappe.utils.make_random import add_random_children, get_random
-from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
-from erpnext.demo.domains import data
+import json
+import random
+
+import frappe
from frappe import _
+from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
+from frappe.utils import cstr, flt, now_datetime, random_string
+from frappe.utils.make_random import add_random_children, get_random
+from frappe.utils.nestedset import get_root_of
+
+import erpnext
+from erpnext.demo.domains import data
+
def setup(domain):
frappe.flags.in_demo = 1
diff --git a/erpnext/demo/user/accounts.py b/erpnext/demo/user/accounts.py
index 7fab772..2a24824 100644
--- a/erpnext/demo/user/accounts.py
+++ b/erpnext/demo/user/accounts.py
@@ -4,19 +4,25 @@
from __future__ import unicode_literals
-import erpnext
-import frappe
import random
-from frappe.utils import random_string
+
+import frappe
from frappe.desk import query_report
+from frappe.utils import random_string
+from frappe.utils.make_random import get_random
+
+import erpnext
from erpnext.accounts.doctype.journal_entry.journal_entry import get_payment_entry_against_invoice
from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
-from frappe.utils.make_random import get_random
-from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, make_payment_entry
+from erpnext.accounts.doctype.payment_request.payment_request import (
+ make_payment_entry,
+ make_payment_request,
+)
from erpnext.demo.user.sales import make_sales_order
from erpnext.selling.doctype.sales_order.sales_order import make_sales_invoice
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_invoice
+
def work():
frappe.set_user(frappe.db.get_global('demo_accounts_user'))
diff --git a/erpnext/demo/user/education.py b/erpnext/demo/user/education.py
index 883a6d8..adc0463 100644
--- a/erpnext/demo/user/education.py
+++ b/erpnext/demo/user/education.py
@@ -4,13 +4,21 @@
from __future__ import unicode_literals
-import frappe
import random
+from datetime import timedelta
+
+import frappe
from frappe.utils import cstr
from frappe.utils.make_random import get_random
-from datetime import timedelta
-from erpnext.education.api import get_student_group_students, make_attendance_records, enroll_student, \
- get_fee_schedule, collect_fees, get_course
+
+from erpnext.education.api import (
+ collect_fees,
+ enroll_student,
+ get_course,
+ get_fee_schedule,
+ get_student_group_students,
+ make_attendance_records,
+)
def work():
diff --git a/erpnext/demo/user/fixed_asset.py b/erpnext/demo/user/fixed_asset.py
index dc094e1..ec0e4c8 100644
--- a/erpnext/demo/user/fixed_asset.py
+++ b/erpnext/demo/user/fixed_asset.py
@@ -6,6 +6,7 @@
import frappe
from frappe.utils.make_random import get_random
+
from erpnext.assets.doctype.asset.asset import make_sales_invoice
from erpnext.assets.doctype.asset.depreciation import post_depreciation_entries, scrap_asset
diff --git a/erpnext/demo/user/hr.py b/erpnext/demo/user/hr.py
index 0211bc8..17d5829 100644
--- a/erpnext/demo/user/hr.py
+++ b/erpnext/demo/user/hr.py
@@ -1,15 +1,23 @@
from __future__ import unicode_literals
-import frappe, erpnext
-import random
+
import datetime
-from frappe.utils import random_string, add_days, get_last_day, getdate
+import random
+
+import frappe
+from frappe.utils import add_days, get_last_day, getdate, random_string
+from frappe.utils.make_random import get_random
+
+import erpnext
+from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry
+from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account
+from erpnext.hr.doctype.leave_application.leave_application import (
+ AttendanceAlreadyMarkedError,
+ OverlapError,
+ get_leave_balance_on,
+)
from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
from erpnext.projects.doctype.timesheet.timesheet import make_salary_slip, make_sales_invoice
-from frappe.utils.make_random import get_random
-from erpnext.hr.doctype.expense_claim.test_expense_claim import get_payable_account
-from erpnext.hr.doctype.expense_claim.expense_claim import make_bank_entry
-from erpnext.hr.doctype.leave_application.leave_application import (get_leave_balance_on,
- OverlapError, AttendanceAlreadyMarkedError)
+
def work():
frappe.set_user(frappe.db.get_global('demo_hr_user'))
diff --git a/erpnext/demo/user/manufacturing.py b/erpnext/demo/user/manufacturing.py
index bece079..6e01f0f 100644
--- a/erpnext/demo/user/manufacturing.py
+++ b/erpnext/demo/user/manufacturing.py
@@ -3,21 +3,23 @@
from __future__ import unicode_literals
-import frappe, random, erpnext
+import random
from datetime import timedelta
-from frappe.utils.make_random import how_many
+
+import frappe
from frappe.desk import query_report
-from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError
+from frappe.utils.make_random import how_many
+
+import erpnext
from erpnext.manufacturing.doctype.work_order.test_work_order import make_wo_order_test_record
+
def work():
if random.random() < 0.3: return
frappe.set_user(frappe.db.get_global('demo_manufacturing_user'))
if not frappe.get_all('Sales Order'): return
- from erpnext.projects.doctype.timesheet.timesheet import OverlapError
-
ppt = frappe.new_doc("Production Plan")
ppt.company = erpnext.get_default_company()
# ppt.use_multi_level_bom = 1 #refactored
@@ -68,9 +70,12 @@
def make_stock_entry_from_pro(pro_id, purpose):
from erpnext.manufacturing.doctype.work_order.work_order import make_stock_entry
+ from erpnext.stock.doctype.stock_entry.stock_entry import (
+ DuplicateEntryForWorkOrderError,
+ IncorrectValuationRateError,
+ OperationsNotCompleteError,
+ )
from erpnext.stock.stock_ledger import NegativeStockError
- from erpnext.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \
- DuplicateEntryForWorkOrderError, OperationsNotCompleteError
try:
st = frappe.get_doc(make_stock_entry(pro_id, purpose))
diff --git a/erpnext/demo/user/projects.py b/erpnext/demo/user/projects.py
index 044e296..b6b99de 100644
--- a/erpnext/demo/user/projects.py
+++ b/erpnext/demo/user/projects.py
@@ -3,11 +3,14 @@
from __future__ import unicode_literals
-import frappe, erpnext
+import frappe
from frappe.utils import flt
from frappe.utils.make_random import get_random
-from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
+
+import erpnext
from erpnext.demo.user.hr import make_sales_invoice_for_timesheet
+from erpnext.projects.doctype.timesheet.test_timesheet import make_timesheet
+
def run_projects(current_date):
frappe.set_user(frappe.db.get_global('demo_projects_user'))
diff --git a/erpnext/demo/user/purchase.py b/erpnext/demo/user/purchase.py
index b7aca79..ec32f97 100644
--- a/erpnext/demo/user/purchase.py
+++ b/erpnext/demo/user/purchase.py
@@ -3,15 +3,22 @@
from __future__ import unicode_literals
-import frappe, random, json, erpnext
-from frappe.utils.make_random import how_many, get_random
+import json
+import random
+
+import frappe
from frappe.desk import query_report
-from erpnext.setup.utils import get_exchange_rate
+from frappe.utils.make_random import get_random, how_many
+
+import erpnext
from erpnext.accounts.party import get_party_account_currency
+from erpnext.buying.doctype.request_for_quotation.request_for_quotation import (
+ make_supplier_quotation_from_rfq,
+)
from erpnext.exceptions import InvalidCurrency
+from erpnext.setup.utils import get_exchange_rate
from erpnext.stock.doctype.material_request.material_request import make_request_for_quotation
-from erpnext.buying.doctype.request_for_quotation.request_for_quotation import \
- make_supplier_quotation_from_rfq
+
def work():
frappe.set_user(frappe.db.get_global('demo_purchase_user'))
diff --git a/erpnext/demo/user/sales.py b/erpnext/demo/user/sales.py
index 8d5ba28..95494ee 100644
--- a/erpnext/demo/user/sales.py
+++ b/erpnext/demo/user/sales.py
@@ -3,12 +3,20 @@
from __future__ import unicode_literals
-import frappe, random, erpnext
+import random
+
+import frappe
from frappe.utils import flt
from frappe.utils.make_random import add_random_children, get_random
-from erpnext.setup.utils import get_exchange_rate
+
+import erpnext
+from erpnext.accounts.doctype.payment_request.payment_request import (
+ make_payment_entry,
+ make_payment_request,
+)
from erpnext.accounts.party import get_party_account_currency
-from erpnext.accounts.doctype.payment_request.payment_request import make_payment_request, make_payment_entry
+from erpnext.setup.utils import get_exchange_rate
+
def work(domain="Manufacturing"):
frappe.set_user(frappe.db.get_global('demo_sales_user_2'))
diff --git a/erpnext/demo/user/stock.py b/erpnext/demo/user/stock.py
index d44da7d..188fc13 100644
--- a/erpnext/demo/user/stock.py
+++ b/erpnext/demo/user/stock.py
@@ -3,13 +3,18 @@
from __future__ import print_function, unicode_literals
-import frappe, random, erpnext
+import random
+
+import frappe
from frappe.desk import query_report
-from erpnext.stock.stock_ledger import NegativeStockError
-from erpnext.stock.doctype.serial_no.serial_no import SerialNoRequiredError, SerialNoQtyError
+
+import erpnext
from erpnext.stock.doctype.batch.batch import UnableToSelectBatchError
from erpnext.stock.doctype.delivery_note.delivery_note import make_sales_return
from erpnext.stock.doctype.purchase_receipt.purchase_receipt import make_purchase_return
+from erpnext.stock.doctype.serial_no.serial_no import SerialNoQtyError, SerialNoRequiredError
+from erpnext.stock.stock_ledger import NegativeStockError
+
def work():
frappe.set_user(frappe.db.get_global('demo_manufacturing_user'))
@@ -66,8 +71,10 @@
def make_stock_reconciliation():
# random set some items as damaged
- from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation \
- import OpeningEntryAccountError, EmptyStockReconciliationItemsError
+ from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import (
+ EmptyStockReconciliationItemsError,
+ OpeningEntryAccountError,
+ )
if random.random() < 0.4:
stock_reco = frappe.new_doc("Stock Reconciliation")
@@ -88,8 +95,11 @@
frappe.db.rollback()
def submit_draft_stock_entries():
- from erpnext.stock.doctype.stock_entry.stock_entry import IncorrectValuationRateError, \
- DuplicateEntryForWorkOrderError, OperationsNotCompleteError
+ from erpnext.stock.doctype.stock_entry.stock_entry import (
+ DuplicateEntryForWorkOrderError,
+ IncorrectValuationRateError,
+ OperationsNotCompleteError,
+ )
# try posting older drafts (if exists)
frappe.db.commit()