Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cli/core/accounts/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .app import app # noqa
from cli.core.accounts.app import app

__all__ = ["app"]
6 changes: 4 additions & 2 deletions cli/core/accounts/constants.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from types import MappingProxyType

CREATING = "creating"
FETCHING = "fetching"
READING = "reading"
REMOVING = "removing"

STATUS_MSG = {
STATUS_MSG = MappingProxyType({
CREATING: "Making account",
FETCHING: "Fetching account information",
READING: "Reading accounts from the configuration file",
REMOVING: "Removing account",
}
})
4 changes: 3 additions & 1 deletion cli/core/price_lists/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .app import app # noqa
from cli.core.price_lists.app import app

__all__ = ["app"]
4 changes: 3 additions & 1 deletion cli/core/price_lists/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections.abc import Mapping
from types import MappingProxyType
from typing import Any

ERROR_COLUMN_NAME = "Error"
Expand All @@ -8,7 +10,7 @@
TAB_PRICE_ITEMS,
)

REQUIRED_FIELDS_BY_TAB: dict[str, Any] = {}
REQUIRED_FIELDS_BY_TAB: Mapping[str, Any] = MappingProxyType({})

GENERAL_PRICELIST_ID = "Pricelist ID"
GENERAL_CURRENCY = "Currency"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from types import MappingProxyType

from cli.core.handlers.vertical_tab_file_manager import VerticalTabFileManager
from cli.core.price_lists.constants import (
GENERAL_FIELDS,
Expand All @@ -18,5 +16,5 @@ class PriceListExcelFileManager(VerticalTabFileManager):
_fields = GENERAL_FIELDS
_id_field = GENERAL_PRICELIST_ID
_required_tabs = REQUIRED_TABS
_required_fields_by_tab = MappingProxyType(REQUIRED_FIELDS_BY_TAB)
_required_fields_by_tab = REQUIRED_FIELDS_BY_TAB
_sheet_name = TAB_GENERAL
4 changes: 3 additions & 1 deletion cli/core/products/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .app import app # noqa
from cli.core.products.app import app

__all__ = ["app"]
14 changes: 8 additions & 6 deletions cli/core/products/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from types import MappingProxyType

ID_COLUMN_NAME = "ID"
ACTION_COLUMN_NAME = "Action"
CREATED_COLUMN_NAME = "Created"
Expand Down Expand Up @@ -271,7 +273,7 @@
SETTINGS_SETTING,
SETTINGS_VALUE,
)
SETTINGS_API_MAPPING = {
SETTINGS_API_MAPPING = MappingProxyType({
"Change order validation (draft)": "preValidation.changeOrderDraft",
"Item selection validation": "itemSelection",
"Order queue changes notification": "orderQueueChanges",
Expand All @@ -283,15 +285,15 @@
"Purchase order validation (draft)": "preValidation.purchaseOrderDraft",
"Purchase order validation (query)": "preValidation.purchaseOrderQuery",
"Termination order validation (draft)": "preValidation.terminationOrder",
}
})
SETTINGS_FIELDS = (
SETTINGS_SETTING,
SETTINGS_ACTION,
SETTINGS_VALUE,
)


REQUIRED_FIELDS_BY_TAB = {
REQUIRED_FIELDS_BY_TAB = MappingProxyType({
TAB_GENERAL: GENERAL_REQUIRED_FIELDS,
TAB_PARAMETERS_GROUPS: PARAMETERS_GROUPS_REQUIRED_FIELDS,
TAB_ITEMS_GROUPS: ITEMS_GROUPS_REQUIRED_FIELDS,
Expand All @@ -302,8 +304,8 @@
TAB_ITEMS: ITEMS_REQUIRED_FIELDS,
TAB_TEMPLATES: TEMPLATES_REQUIRED_FIELDS,
TAB_SETTINGS: SETTINGS_REQUIRED_FIELDS,
}
})

REQUIRED_FIELDS_WITH_VALUES_BY_TAB = {
REQUIRED_FIELDS_WITH_VALUES_BY_TAB = MappingProxyType({
TAB_GENERAL: GENERAL_REQUIRED_FIELDS_WITH_VALUES,
}
})
4 changes: 1 addition & 3 deletions cli/core/products/handlers/product_excel_file_manager.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from types import MappingProxyType

from cli.core.handlers.vertical_tab_file_manager import VerticalTabFileManager
from cli.core.products.constants import (
GENERAL_FIELDS,
Expand All @@ -18,5 +16,5 @@ class ProductExcelFileManager(VerticalTabFileManager):
_fields = GENERAL_FIELDS
_id_field = GENERAL_PRODUCT_ID
_required_tabs = REQUIRED_TABS
_required_fields_by_tab = MappingProxyType(REQUIRED_FIELDS_BY_TAB)
_required_fields_by_tab = REQUIRED_FIELDS_BY_TAB
_sheet_name = TAB_GENERAL
39 changes: 20 additions & 19 deletions cli/core/stats.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import copy
from abc import ABC, abstractmethod
from typing import TypedDict

Expand All @@ -23,12 +22,14 @@ class TabResults(TypedDict):
skipped: int


DEFAULT_RESULTS: TabResults = {
"synced": 0,
"error": 0,
"total": 0,
"skipped": 0,
}
def default_results() -> TabResults:
"""Create a fresh statistics container."""
return {
"synced": 0,
"error": 0,
"total": 0,
"skipped": 0,
}


class ErrorMessagesCollector:
Expand Down Expand Up @@ -186,16 +187,16 @@ class ProductStatsCollector(StatsCollector):
"""Statistics collector specifically for product synchronization operations."""

def __init__(self) -> None:
general: TabResults = copy.deepcopy(DEFAULT_RESULTS)
parameters_groups: TabResults = copy.deepcopy(DEFAULT_RESULTS)
items_groups: TabResults = copy.deepcopy(DEFAULT_RESULTS)
agreements_parameters: TabResults = copy.deepcopy(DEFAULT_RESULTS)
asset_parameters: TabResults = copy.deepcopy(DEFAULT_RESULTS)
item_parameters: TabResults = copy.deepcopy(DEFAULT_RESULTS)
request_parameters: TabResults = copy.deepcopy(DEFAULT_RESULTS)
subscription_parameters: TabResults = copy.deepcopy(DEFAULT_RESULTS)
item_rows: TabResults = copy.deepcopy(DEFAULT_RESULTS)
templates: TabResults = copy.deepcopy(DEFAULT_RESULTS)
general: TabResults = default_results()
parameters_groups: TabResults = default_results()
items_groups: TabResults = default_results()
agreements_parameters: TabResults = default_results()
asset_parameters: TabResults = default_results()
item_parameters: TabResults = default_results()
request_parameters: TabResults = default_results()
subscription_parameters: TabResults = default_results()
item_rows: TabResults = default_results()
templates: TabResults = default_results()

tabs = {
"General": general,
Expand Down Expand Up @@ -225,8 +226,8 @@ class PriceListStatsCollector(StatsCollector):
"""

def __init__(self) -> None:
general: TabResults = copy.deepcopy(DEFAULT_RESULTS)
price_items: TabResults = copy.deepcopy(DEFAULT_RESULTS)
general: TabResults = default_results()
price_items: TabResults = default_results()

tabs = {
"General": general,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ select = ["AAA", "E999", "WPS"]
show-source = true
statistics = false
per-file-ignores = [
"*.py:WPS204,WPS210,WPS211,WPS213,WPS214,WPS218,WPS221,WPS229,WPS231,WPS232,WPS234,WPS235,WPS237,WPS322,WPS327,WPS332,WPS335,WPS336,WPS338,WPS339,WPS342,WPS347,WPS349,WPS400,WPS407,WPS410,WPS412,WPS420,WPS432,WPS458",
"*.py:WPS204,WPS210,WPS211,WPS213,WPS214,WPS218,WPS221,WPS229,WPS231,WPS232,WPS234,WPS235,WPS237,WPS322,WPS327,WPS332,WPS335,WPS336,WPS338,WPS339,WPS342,WPS347,WPS349,WPS410,WPS412,WPS432",
"tests/**:WPS202,WPS203,WPS204,WPS210,WPS211,WPS213,WPS218,WPS221,WPS235,WPS322,WPS335,WPS339,WPS342,WPS432"
]

Expand Down
Loading