Skip to content

3. Кательников Кирилл Владимирович. 614 - #108

Open
Kirill-us wants to merge 14 commits into
python-department:mainfrom
Kirill-us:main3
Open

Kirill-us wants to merge 14 commits into
python-department:mainfrom
Kirill-us:main3

Conversation

@Kirill-us

Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot added the 614 label Oct 9, 2026
Comment thread src/part3/crud.py
name1, price, quan = fields
name = normalize_product_name(name1)

if name == "":

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/part3/crud.py
return None

if any(product[NAME_INDEX] == name for product in storage):
print(f"product name '{name}' is already taken")

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.

Можно было бы добавить кавычки к строке с помощью форматирования f-строк:

Suggested change
print(f"product name '{name}' is already taken")
print(f"product name {name!r} is already taken")

Comment thread src/part3/run_admin.py
print_result(result)
return True

print(f"{line!s} is not a command")

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.

Здесь форматирование !s не обязательно. По умолчанию в f-строках все форматируется через этот тип форматирования.

Suggested change
print(f"{line!s} is not a command")
print(f"{line} is not a command")

Comment thread src/part3/run_admin.py

words = line.split()

if len(words) >= 4 and words[0] == "create":

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.

Из-за использования ветвления для проверки состава строки, очень много логики дублируется: проверка количества элементов, выполнение срезов и т.д. Это нарушение критерия S1. Минус балл

Чтобы избежать такого дублирования, стоило использовать match-case. Этот механизм идеально подходит для сопоставления шаблонов.

Comment thread src/part3/run_admin.py
if len(words) >= 4 and words[0] == "create":
name = " ".join(words[1:-2])
price = Decimal(words[-2])
quantity = int(words[-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.

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

Comment thread src/part3/utils.py
"""
# TODO: реализуйте функцию
return ""
ids = []

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.

В этой функции очень много копипасты. Всю повторяющуюся логику следовало вынести в отдельную функцию, чтобы избежать форматирования. Возможно, следовало бы в целом разбить эту функцию на несколько единоответственных функций. А то эта функция сейчас делает несколько действий: определяет размер полей, формирует итоговое строковое представление.

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

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