Skip to content

2. Кабанов Дмитрий Константинович. 614 - #90

Open
Dmitrii89-svg wants to merge 7 commits into
python-department:mainfrom
Dmitrii89-svg:Dz#2
Open

Dmitrii89-svg wants to merge 7 commits into
python-department:mainfrom
Dmitrii89-svg:Dz#2

Conversation

@Dmitrii89-svg

Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot added the 614 label Oct 2, 2026

@EvgrafovMichail EvgrafovMichail left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Старайтесь не использовать магических констант, а общую логику держать в одном месте, например, в одной функции. Так код будет легче сопровождать и расширять

Comment thread src/part2/crud.py
else:
for i in range(len(storage)):
idmax = max(storage[i][0], idmax)
return idmax + 1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Не очень понятно, зачем увеличивать idmax на 1 в конце. Из-за этого все id будут на 1 больше, чем требовалось и часть тестов не пройдут.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Неправильная проверка на пустоту. Нарушение критерия T4, минус 0.25 балла

Comment thread src/part2/crud.py
idmax = PRODUCT_ID_MIN
else:
for i in range(len(storage)):
idmax = max(storage[i][0], idmax)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Здесь и далее для индексации кортежей используются магические константы (0, 1 и т.д.). Это усложняет чтение кода. К тому же, если структура кортежа поменяется (например, поле с ценой и поле с количеством поменяются местами), придется вручную править все вхождения.
Нарушение критерия S3, минус балл.

Comment thread src/part2/crud.py
if len(storage) == 0:
idmax = PRODUCT_ID_MIN
else:
for i in range(len(storage)):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Нарушение критерия T5. Минус 0.25 балла.

Comment thread src/part2/crud.py
``price`` is a :class:`~decimal.Decimal` amount and is rounded
to the stored money precision before it is saved.
for i in range(len(storage)):
if fields[0] == storage[i][1]:

Copy link
Copy Markdown
Member

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
if product is None:
return None
else:
if product[3] < quantity:

Copy link
Copy Markdown
Member

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
product = read_product(storage, product_id)
if product is None:
return None
else:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Нарушение критерия T1. Минус 0.25 балла

Comment thread src/part2/cart.py
f"not enough stock for product {product_id}: {product[3]} available, {quantity} requested"
)
return None
else:

Copy link
Copy Markdown
Member

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
storage[indp][2],
storage[indp][3] - quantity,
)
for i in range(len(cart)):

Copy link
Copy Markdown
Member

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
if product is None:
return None
else:
indp = storage.index(product)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Это логика отчасти дублирует похожую логику в функции add_to_cart. Это нарушение критерия S1. Минус балл

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants