I have a class that looks like this:
class Product(BaseModel):
code: str = ...
discription_one: str = ...
famille: FamilleProduct
sou_famille: SouFamileProduct
parent: ParentProduct
sou_parent: SouParentProduct
group: GroupProduct
sou_group: SouGroupProduct
reference: Optional[str] = ''
oem: Optional[str] = ''
other_code: Optional[str] = ''
discription_two: Optional[str] = ''
discription_three: Optional[str] = ''
remarque: Optional[str] = ''
marque: Marque
origine: Country
unite: UniteProduct
code_sh: ShCode
numbre_serie: NumbreSerie
qr_code: QrProduct
status: StatusProduct
product_visible: bool = True
product_loocked: bool = False
product_hided: bool = False
location: LocationProduct
last_prix_achat: float = 0.00
pmp_achat: float = 0.00
prix_achat_devise: List[PrixAchat]
prix_vente: List[PrixVente]
tva: TvaProduct
tax: TaxProduct
qtt_achat: float = 0.00
qtt_actuel: float = 0.00
qtt_vente: float = 0.00
qtt_min: float = 0.00
qtt_max: float = 0.00
qtt_arrivage: float = 0.00
qtt_cmdfr: float = 0.00
qtt_cmdcl: float = 0.00
date_fab: datetime = None
date_exp: datetime = None
created_at: datetime = None
updated_at: datetime = None
images: List[ImageProduct] = None
When I try to write a function to create this model, I find myself dealing with a function with too many parameters:
def creat_product(self,a: str, b: str, c: None, d: None, e: None, f: None, g: None, h: None, i: str
j: str, k: str, l: str, m: str, n: str) -> Product:
return Product(
code=a,
discription_one=b,
famille=c,
sou_famille=d,
parent=e,
sou_parent=f,
group=g,
sou_group=h,
reference=i,
oem=j,
other_code=k,
discription_two=l,
discription_three=m,
remarque=n,...# and other paramaters)
For all the paramaters with None
values, is it possible to add them when calling creat_product
or keep them None
? Is there any other way to do this?