Skip to content

3. Спиридонов Олег Станиславович. 613 - #39

Closed
SpiridonovOleg wants to merge 17 commits into
python-department:mainfrom
SpiridonovOleg:main
Closed

SpiridonovOleg wants to merge 17 commits into
python-department:mainfrom
SpiridonovOleg:main

Conversation

@SpiridonovOleg

Copy link
Copy Markdown

No description provided.

@SpiridonovOleg SpiridonovOleg changed the title 1. Спиридонов Олег Станиславович. 613. 1. Спиридонов Олег Станиславович. 613 Oct 2, 2026
@github-actions github-actions Bot added the 613 label Oct 2, 2026
@SpiridonovOleg SpiridonovOleg changed the title 1. Спиридонов Олег Станиславович. 613 2. Спиридонов Олег Станиславович. 613 Oct 4, 2026
@SpiridonovOleg SpiridonovOleg changed the title 2. Спиридонов Олег Станиславович. 613 3. Спиридонов Олег Станиславович. 613 Oct 12, 2026
Comment thread src/part1/snowflake.py
return None

return (
(timestamp_ms << (NODE_ID_BITS + SEQUENCE_ID_BITS))

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.

Вычисление сдвига дублировано в функции decode_timestamp_ms. Это может быть опасно, так как если логика поменяется, то надо будет исправлять в 2х местах, а это можно забыть, поэтому лучше было вынести вычисление в отдельную константу.
Пункт S1, минус балл.

Comment thread src/part2/cart.py
def change_cart_quantity(
cart: list[CartLine], cartline: CartLine, quantity: int
) -> None:
cart.append(

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.

Что-то вы перемудрили с обновлением значений. Зачем было каждый раз удалять и добавлять, если можно просто саму строку заменить

cart[ind] = (cartline[LINE_PRODUCT_ID_INDEX], cartline[LINE_QUANTITY_INDEX] + quantity)

У меня даже тесты упали, но пожалуй не буду снижать.
Но в следующий раз не усложняйте :)

Comment thread src/part2/cart.py
"""
# TODO: реализуйте функцию
return (0, 0)
changable_cartline = find_cart_line(cart, 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.

Тут уже на грани пункта S2. Понимаю, что тут ruff постарался, но лучше было бы вынести какие-то вычисления на отдельные строки, чтобы избежать слишком длинных строк. Пока не снижаю, но чтобы больше я такого не видел.

Comment thread src/part3/crud.py
if not normalized_name:
print("product name must not be blank")
return None
elif normalized_name in (product[NAME_INDEX] for product in storage):

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.

Пункт T1

Comment thread src/part3/run_admin.py
return True

match splitted_line.pop(0):
case "help" if not splitted_line:

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.

Для такого условия, если можно было бы написать

match splitted_line:
   case ["help"]:

Comment thread src/part3/run_admin.py
)
)
return True
case "read" if len(splitted_line) == 1:

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.

Для такого условия можно было написать:

case ["read", product_id]

Comment thread src/part3/crud.py
new_product = (
product_id,
normalized_name,
normalize_price(fields[1]),

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.

Магические константы
Пункт S3

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