from dataclasses import dataclass, field
from typing import List
@dataclass()
class Product():
plu: int
name: str = ''
bar_codes: List[BarCode] = field(default_factory=list)
@dataclass()
class BarCode():
product_id: int
bar_code: str
if __name__ == "__main__":
barcodes = [BarCode(1,'111'), BarCode(1, '222')]
prod = Product(1,"Молоко", barcodes)
print(prod.bar_codes)