Skip to content

2. Шемякин Николай Александрович. 613 - #33

Closed
shiba-rose wants to merge 12 commits into
python-department:mainfrom
shiba-rose:main
Closed

shiba-rose wants to merge 12 commits into
python-department:mainfrom
shiba-rose:main

Conversation

@shiba-rose

Copy link
Copy Markdown

No description provided.

@shiba-rose shiba-rose changed the title 001- Шемякин Николай Александрович 613 1. Шемякин Николай Александрович. 613 Sep 26, 2026
@github-actions github-actions Bot added the 613 label Sep 26, 2026
@shiba-rose shiba-rose changed the title 1. Шемякин Николай Александрович. 613 2. Шемякин Николай Александрович. 613 Oct 2, 2026
Comment thread src/part1/snowflake.py
if timestamp_ms > TIMESTAMP_MS_MAX:
return print("overflows")

timestamp_ms_snowflake_id = timestamp_ms << (SEQUENCE_ID_BITS + NODE_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/crud.py
"""
# TODO: реализуйте функцию
return (0, "", Decimal(0), 0)
for product in storage:

@Avshugan Avshugan Oct 21, 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/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
# TODO: реализуйте функцию
return (0, 0)
line = find_cart_line(cart, product_id)
if line == None:

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.

Пункт Т3

Comment thread src/part2/crud.py
"""
# TODO: реализуйте функцию
return 0
if len(storage) == 0:

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.

Пункт T4

Comment thread src/part3/crud.py Outdated
for index, product in enumerate(storage):
if product[PRODUCT_ID_INDEX] == product_id:
for other_product in storage:
if (

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.

Слишком большая вложеность
Пункт M1

Comment thread src/part3/utils.py Outdated
return "\n".join(table_rows)


storage: list[tuple[int, str, Decimal, int]] = []

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.

Пункт M4

Comment thread src/part3/utils.py Outdated
return ""
column_width = [len(header) for header in TABLE_HEADERS]
for product in storage:
column_width[0] = max(column_width[0], len(str(product[0])))

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.

А почему просто не сделать цикл? Ниже тоже самое.
Пункт S1

Comment thread src/part3/utils.py Outdated
for product in storage:
id, name, price, quantity = map(str, product)
row_mas = [
f" {id.ljust(column_width[0])} ",

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.

Тут 0, 1, 2, 3 фактически являются магическими константами, так как если у вас поменяются местами name и price, то и индексы надо будет менять местами.
Пункт S3

@shiba-rose shiba-rose closed this Nov 1, 2026
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