from dataclasses import dataclass, field
from random import choice
from typing import Optional


def choice_color():
    print('Start choice')
    colors = ['black', 'white', 'red', 'green']
    return choice(colors)

@dataclass
class InventoryItem:
    name: str
    quantity: int = field(default=1)
    price: float = field(default=9.99)
    color: str = field(default_factory=choice_color)


def test_1():
    desk = InventoryItem('Computer desk')
    print(desk)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'''Если нужен пустой список'''
@dataclass
class MyDataclass:
    foo: str = field(default_factory=list)


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@dataclass
class Location:
    name: str
    longitude: float = field(default=0)
    latitude: float = field(default=11.5)


def test_2():

    stonehenge = Location('Stonehenge', 51, 1.5)
    print(stonehenge)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@dataclass
class Person:
    first_name: str
    last_name: str
    hobbies: set = field(default_factory=set)



def main():
    # test_1()
    test_2()


if __name__ == '__main__':
    main()