From 1bc0b40a2e534ba5ccde07703116f14b2b6066c2 Mon Sep 17 00:00:00 2001 From: Mihir Kandoi Date: Wed, 18 Feb 2026 11:52:21 +0530 Subject: [PATCH] refactor(subcontracting): add arg type hints to functions --- .../subcontracting_bom/subcontracting_bom.py | 2 +- .../subcontracting_inward_order.py | 11 ++++++----- .../subcontracting_order/subcontracting_order.py | 9 +++++---- .../subcontracting_receipt.py | 15 +++++++++++---- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.py b/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.py index f2f1e26865c..ef8c8ab2e94 100644 --- a/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.py +++ b/erpnext/subcontracting/doctype/subcontracting_bom/subcontracting_bom.py @@ -84,7 +84,7 @@ class SubcontractingBOM(Document): @frappe.whitelist() -def get_subcontracting_boms_for_finished_goods(fg_items: str | list) -> dict: +def get_subcontracting_boms_for_finished_goods(fg_items: str | list): if fg_items: filters = {"is_active": 1} diff --git a/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.py b/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.py index b516518bfcb..b06b6fc39a2 100644 --- a/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_inward_order/subcontracting_inward_order.py @@ -3,6 +3,7 @@ import frappe from frappe import _ +from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc from frappe.utils import comma_and, flt, get_link_to_form @@ -322,7 +323,7 @@ class SubcontractingInwardOrder(SubcontractingController): frappe.msgprint(_("{0} created").format(comma_and(doc_list))) @frappe.whitelist() - def make_rm_stock_entry_inward(self, target_doc=None): + def make_rm_stock_entry_inward(self, target_doc: Document | str | None = None): def calculate_qty_as_per_bom(rm_item): data = frappe.get_value( "Subcontracting Inward Order Item", @@ -385,7 +386,7 @@ class SubcontractingInwardOrder(SubcontractingController): return stock_entry.as_dict() @frappe.whitelist() - def make_rm_return(self, target_doc=None): + def make_rm_return(self, target_doc: Document | str | None = None): if target_doc and target_doc.get("items"): target_doc.items = [] @@ -426,7 +427,7 @@ class SubcontractingInwardOrder(SubcontractingController): return stock_entry.as_dict() @frappe.whitelist() - def make_subcontracting_delivery(self, target_doc=None): + def make_subcontracting_delivery(self, target_doc: Document | str | None = None): if target_doc and target_doc.get("items"): target_doc.items = [] @@ -502,7 +503,7 @@ class SubcontractingInwardOrder(SubcontractingController): return stock_entry.as_dict() @frappe.whitelist() - def make_subcontracting_return(self, target_doc=None): + def make_subcontracting_return(self, target_doc: Document | str | None = None): if target_doc and target_doc.get("items"): target_doc.items = [] @@ -548,7 +549,7 @@ class SubcontractingInwardOrder(SubcontractingController): @frappe.whitelist() -def update_subcontracting_inward_order_status(scio, status=None): +def update_subcontracting_inward_order_status(scio: str | Document, status: str | None = None): if isinstance(scio, str): scio = frappe.get_doc("Subcontracting Inward Order", scio) diff --git a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py index 8eb369d120f..4965ba1586d 100644 --- a/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py +++ b/erpnext/subcontracting/doctype/subcontracting_order/subcontracting_order.py @@ -3,6 +3,7 @@ import frappe from frappe import _ +from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc from frappe.utils import flt @@ -363,7 +364,7 @@ class SubcontractingOrder(SubcontractingController): ) @frappe.whitelist() - def reserve_raw_materials(self, items=None, stock_entry=None): + def reserve_raw_materials(self, items: list | None = None, stock_entry: str | None = None): if self.reserve_stock: item_dict = {} @@ -437,7 +438,7 @@ class SubcontractingOrder(SubcontractingController): return False @frappe.whitelist() - def cancel_stock_reservation_entries(self, sre_list=None, notify=True) -> None: + def cancel_stock_reservation_entries(self, sre_list: list | None = None, notify: bool = True): from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import ( cancel_stock_reservation_entries, ) @@ -448,7 +449,7 @@ class SubcontractingOrder(SubcontractingController): @frappe.whitelist() -def make_subcontracting_receipt(source_name, target_doc=None): +def make_subcontracting_receipt(source_name: str, target_doc: Document | str | None = None): items = frappe.flags.args.get("items") if frappe.flags.args else None return get_mapped_subcontracting_receipt(source_name, target_doc, items=items) @@ -495,7 +496,7 @@ def get_mapped_subcontracting_receipt(source_name, target_doc=None, items=None): @frappe.whitelist() -def update_subcontracting_order_status(sco, status=None): +def update_subcontracting_order_status(sco: str | Document, status: str | None = None): if isinstance(sco, str): sco = frappe.get_doc("Subcontracting Order", sco) diff --git a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py index 2456e2ef90f..b13419cc4cf 100644 --- a/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py +++ b/erpnext/subcontracting/doctype/subcontracting_receipt/subcontracting_receipt.py @@ -5,6 +5,7 @@ from collections import defaultdict import frappe from frappe import _ +from frappe.model.document import Document from frappe.model.mapper import get_mapped_doc from frappe.query_builder.functions import Sum from frappe.utils import cint, flt, get_link_to_form, getdate, nowdate @@ -343,7 +344,7 @@ class SubcontractingReceipt(SubcontractingController): self.update_rate_for_supplied_items() @frappe.whitelist() - def get_scrap_items(self, recalculate_rate=False): + def get_scrap_items(self, recalculate_rate: bool = False): self.remove_scrap_items() for item in list(self.items): @@ -930,21 +931,27 @@ class SubcontractingReceipt(SubcontractingController): @frappe.whitelist() -def make_subcontract_return_against_rejected_warehouse(source_name): +def make_subcontract_return_against_rejected_warehouse(source_name: str): from erpnext.controllers.sales_and_purchase_return import make_return_doc return make_return_doc("Subcontracting Receipt", source_name, return_against_rejected_qty=True) @frappe.whitelist() -def make_subcontract_return(source_name, target_doc=None): +def make_subcontract_return(source_name: str, target_doc: Document | str | None = None): from erpnext.controllers.sales_and_purchase_return import make_return_doc return make_return_doc("Subcontracting Receipt", source_name, target_doc) @frappe.whitelist() -def make_purchase_receipt(source_name, target_doc=None, save=False, submit=False, notify=False): +def make_purchase_receipt( + source_name: Document | str, + target_doc: Document | str | None = None, + save: bool = False, + submit: bool = False, + notify: bool = False, +): if isinstance(source_name, str): source_doc = frappe.get_doc("Subcontracting Receipt", source_name) else: