Skip to content

2. Пенская Алина Павловна. 613 - #88

Open
alpen9 wants to merge 16 commits into
python-department:mainfrom
alpen9:main2
Open

alpen9 wants to merge 16 commits into
python-department:mainfrom
alpen9:main2

Conversation

@alpen9

@alpen9 alpen9 commented Oct 2, 2026

Copy link
Copy Markdown

No description provided.

@alpen9 alpen9 changed the title 2. Пенская Алина Павловна. 613. 2. Пенская Алина Павловна. 613 Oct 2, 2026
@github-actions github-actions Bot added the 613 label Oct 2, 2026
Comment thread src/part2/cart.py
"""
# TODO: реализуйте функцию
return (0, 0)
product = read_product(storage, product_id)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше не экономить строки и оставлять пробелы (пустые строки) между логическими блоками. Так читабельность кода улучшается.

Comment thread src/part2/cart.py
),
)
for line in cart:
if line[LINE_PRODUCT_ID_INDEX] == product_id:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут лучше было бы использовать find_cart_line()
Пункт S1

Comment thread src/part2/cart.py
product = update_product(
storage,
product_id,
(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Когда ruff делает такие страшные вещи, то стоит задуматься над тем, чтобы вынести какие-то вычисления на отдельные строки (в данном случае можно было бы создать кортеж и положить его в переменную)
А то читать страшно :)

Comment thread src/part2/crud.py
name, price, quantity = fields
price = normalize_price(price)
for i in range(len(storage)):
product = storage[i]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чтобы такое не писать, надо использовать enumerate.
Пункт T5

Comment thread src/part2/crud.py
# TODO: реализуйте функцию
return 0
for product in storage:
if product[PRODUCT_ID_INDEX] == product_id:

@Avshugan Avshugan Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Цикл:

for index, product in enumerate(storage):
        if product[PRODUCT_ID_INDEX] == product_id:

встречается несколько раз, лучше было бы использовать везде read_product. Код был бы понятнее.
Пункт S1

Comment thread src/part2/crud.py
return PRODUCT_ID_MIN
max_id = 0
for product in storage:
max_id = max(max_id, product[PRODUCT_ID_INDEX])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут кстати можно было бы сделать так:

max_id = max(product[PRODUCT_ID_INDEX] for product in storage)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants