Skip to content

Commit

Permalink
chore: Cleanup imports (#27320)
Browse files Browse the repository at this point in the history
* chore: Added isort to pre-commit config

* chore: Sort imports with isort

* chore: Remove imports with pycln

* chore: Sort imports with isort

* chore: Fix import issues

* chore: Fix sider issues

* chore: linting

* chore: linting / sorting import

from ecommerce refactor merge

* ci: dont allow unused imports

* chore: sort / clean ecommerce imports

Co-authored-by: Ankush Menat <ankush@iwebnotes.com>
  • Loading branch information
ChillarAnand and ankush authored Sep 3, 2021
1 parent 910b9bc commit 4b2be29
Show file tree
Hide file tree
Showing 2,103 changed files with 7,709 additions and 2,971 deletions.
2 changes: 0 additions & 2 deletions .github/helper/.flake8_strict
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ ignore =
E303,
E305,
E306,
E401,
E402,
E501,
E502,
E701,
E702,
E703,
E741,
F401,
F403,
W191,
W291,
Expand Down
2 changes: 1 addition & 1 deletion .github/helper/documentation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import requests
from urllib.parse import urlparse

import requests

docs_repos = [
"frappe_docs",
Expand Down
3 changes: 1 addition & 2 deletions .github/helper/semgrep_rules/frappe_correctness.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import frappe
from frappe import _, flt

from frappe import _
from frappe.model.document import Document


Expand Down
1 change: 0 additions & 1 deletion .github/helper/semgrep_rules/report.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from frappe import _


# ruleid: frappe-missing-translate-function-in-report-python
{"label": "Field Label"}

Expand Down
3 changes: 1 addition & 2 deletions .github/helper/semgrep_rules/ux.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import frappe
from frappe import msgprint, throw, _

from frappe import _, msgprint, throw

# ruleid: frappe-missing-translate-function-python
throw("Error Occured")
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ repos:
args: ['--config', '.github/helper/.flake8_strict']
exclude: ".*setup.py$"

- repo: https://github.com/timothycrosley/isort
rev: 5.9.1
hooks:
- id: isort
exclude: ".*setup.py$"

ci:
autoupdate_schedule: weekly
skip: []
Expand Down
4 changes: 3 additions & 1 deletion erpnext/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import inspect

import frappe

from erpnext.hooks import regional_overrides
from frappe.utils import getdate

__version__ = '13.2.0'

Expand Down
8 changes: 6 additions & 2 deletions erpnext/accounts/custom/address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import frappe
from frappe import _
from frappe.contacts.doctype.address.address import Address
from frappe.contacts.doctype.address.address import get_address_templates, get_address_display
from frappe.contacts.doctype.address.address import (
Address,
get_address_display,
get_address_templates,
)


class ERPNextAddress(Address):
def validate(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals
import frappe, json

import frappe
from frappe import _
from frappe.utils import add_to_date, date_diff, getdate, nowdate, get_last_day, formatdate, get_link_to_form
from erpnext.accounts.report.general_ledger.general_ledger import execute
from frappe.utils import add_to_date, formatdate, get_link_to_form, getdate, nowdate
from frappe.utils.dashboard import cache_source
from frappe.utils.dateutils import get_from_date_from_timespan, get_period_ending
from frappe.utils.nestedset import get_descendants_of


@frappe.whitelist()
@cache_source
def get(chart_name = None, chart = None, no_cache = None, filters = None, from_date = None,
Expand Down
23 changes: 19 additions & 4 deletions erpnext/accounts/deferred_revenue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,26 @@

import frappe
from frappe import _
from frappe.utils import date_diff, add_months, today, getdate, add_days, flt, get_last_day, get_first_day, cint, get_link_to_form, rounded
from erpnext.accounts.utils import get_account_currency
from frappe.email import sendmail_to_system_managers
from frappe.utils.background_jobs import enqueue
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import get_accounting_dimensions
from frappe.utils import (
add_days,
add_months,
cint,
date_diff,
flt,
get_first_day,
get_last_day,
get_link_to_form,
getdate,
rounded,
today,
)

from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
get_accounting_dimensions,
)
from erpnext.accounts.utils import get_account_currency


def validate_service_stop_date(doc):
''' Validates service_stop_date for Purchase Invoice and Sales Invoice '''
Expand Down
4 changes: 3 additions & 1 deletion erpnext/accounts/doctype/account/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals

import frappe
from frappe import _, throw
from frappe.utils import cint, cstr
from frappe import throw, _
from frappe.utils.nestedset import NestedSet, get_ancestors_of, get_descendants_of


class RootNotEditable(frappe.ValidationError): pass
class BalanceMismatchError(frappe.ValidationError): pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals

import json
import os

import frappe, os, json
import frappe
from frappe.utils import cstr
from unidecode import unidecode
from six import iteritems
from frappe.utils.nestedset import rebuild_tree
from six import iteritems
from unidecode import unidecode


def create_charts(company, chart_template=None, existing_company=None, custom_chart=None):
chart = custom_chart or get_chart(chart_template, existing_company)
Expand Down Expand Up @@ -91,11 +94,14 @@ def get_chart(chart_template, existing_company=None):
return get_account_tree_from_existing_company(existing_company)

elif chart_template == "Standard":
from erpnext.accounts.doctype.account.chart_of_accounts.verified import standard_chart_of_accounts
from erpnext.accounts.doctype.account.chart_of_accounts.verified import (
standard_chart_of_accounts,
)
return standard_chart_of_accounts.get()
elif chart_template == "Standard with Numbers":
from erpnext.accounts.doctype.account.chart_of_accounts.verified \
import standard_chart_of_accounts_with_account_number
from erpnext.accounts.doctype.account.chart_of_accounts.verified import (
standard_chart_of_accounts_with_account_number,
)
return standard_chart_of_accounts_with_account_number.get()
else:
folders = ("verified",)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"""
from __future__ import print_function, unicode_literals

import os, json
import ast
import json
import os
from xml.etree import ElementTree as ET
from frappe.utils.csvutils import read_csv_content
import frappe

import frappe
from frappe.utils.csvutils import read_csv_content
from six import iteritems

path = "/Users/nabinhait/projects/odoo/addons"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals

from frappe import _


def get():
return {
_("Application of Funds (Assets)"): {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals

from frappe import _


def get():
return {
_("Application of Funds (Assets)"): {
Expand Down
8 changes: 6 additions & 2 deletions erpnext/accounts/doctype/account/test_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@
# License: GNU General Public License v3. See license.txt

from __future__ import unicode_literals

import unittest

import frappe
from erpnext.stock import get_warehouse_account, get_company_default_inventory_account
from erpnext.accounts.doctype.account.account import update_account_number, merge_account

from erpnext.accounts.doctype.account.account import merge_account, update_account_number
from erpnext.stock import get_company_default_inventory_account, get_warehouse_account


class TestAccount(unittest.TestCase):
def test_rename_account(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
# For license information, please see license.txt

from __future__ import unicode_literals
import frappe
from frappe import _

import json
from frappe.model.document import Document

import frappe
from frappe import _, scrub
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
from frappe import scrub
from frappe.utils import cstr
from frappe.utils.background_jobs import enqueue
from frappe.model import core_doctypes_list
from frappe.model.document import Document
from frappe.utils import cstr


class AccountingDimension(Document):
def before_insert(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice

import frappe

from erpnext.accounts.doctype.journal_entry.test_journal_entry import make_journal_entry
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice

test_dependencies = ['Cost Center', 'Location', 'Warehouse', 'Department']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# For license information, please see license.txt

from __future__ import unicode_literals

# import frappe
from frappe.model.document import Document


class AccountingDimensionDetail(Document):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# For license information, please see license.txt

from __future__ import unicode_literals

import frappe
from frappe import _, scrub
from frappe.model.document import Document


class AccountingDimensionFilter(Document):
def validate(self):
self.validate_applicable_accounts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest

import frappe

from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import (
create_dimension,
disable_dimension,
)
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.accounts.doctype.accounting_dimension.test_accounting_dimension import create_dimension, disable_dimension
from erpnext.exceptions import InvalidAccountDimensionError, MandatoryAccountDimensionError

test_dependencies = ['Location', 'Cost Center', 'Department']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
# For license information, please see license.txt

from __future__ import unicode_literals

import frappe
from frappe.model.document import Document
from frappe import _
from frappe.model.document import Document


class OverlapError(frappe.ValidationError): pass

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
# See license.txt
from __future__ import unicode_literals

import frappe
import unittest
from frappe.utils import nowdate, add_months
from erpnext.accounts.general_ledger import ClosedAccountingPeriod

import frappe
from frappe.utils import add_months, nowdate

from erpnext.accounts.doctype.accounting_period.accounting_period import OverlapError
from erpnext.accounts.doctype.sales_invoice.test_sales_invoice import create_sales_invoice
from erpnext.accounts.general_ledger import ClosedAccountingPeriod

test_dependencies = ['Item']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
# For license information, please see license.txt

from __future__ import unicode_literals

import frappe
from frappe import _
from frappe.utils import cint
from frappe.model.document import Document
from frappe.custom.doctype.property_setter.property_setter import make_property_setter
from frappe.model.document import Document
from frappe.utils import cint


class AccountsSettings(Document):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from __future__ import unicode_literals

import unittest

import frappe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# For license information, please see license.txt

from __future__ import unicode_literals

# import frappe
from frappe.model.document import Document


class AdvanceTaxesandCharges(Document):
pass
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# For license information, please see license.txt

from __future__ import unicode_literals

# import frappe
from frappe.model.document import Document


class AllowedDimension(Document):
pass
Loading

0 comments on commit 4b2be29

Please sign in to comment.