Skip to content

3. Славик Александр Владимирович. 614 - #121

Open
SlavAlVla wants to merge 8 commits into
python-department:mainfrom
SlavAlVla:Solve-task-3
Open

SlavAlVla wants to merge 8 commits into
python-department:mainfrom
SlavAlVla:Solve-task-3

Conversation

@SlavAlVla

Copy link
Copy Markdown

No description provided.

@github-actions github-actions Bot added the 614 label Oct 10, 2026
Comment thread src/part3/crud.py
if not product_name:
print("product name must not be blank")
return None
storage_product_names = [product[NAME_INDEX] for product in 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.

Лучше проверить это условие в цикле, чтобы не перебирать все значения из storage и не выделять дополнительную память для хранения списка имен продуктов

Comment thread src/part3/crud.py
return None

product_id = generate_product_id(storage)
product_price = normalize_price(fields[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/crud.py
print("product name must not be blank")
return None

product_index = -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.

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

Comment thread src/part3/utils.py
max(
max(
[len(str(product[i])) for product in storage] + [0]
), # + [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.

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

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

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/part3/utils.py


# TODO: при необходимости добавьте свои вспомогательные функции
return " ".join(name.split()).lower()


def get_storage_str_representation(storage: list[Product]) -> str:

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. Минус балл

Comment thread src/part3/utils.py
row = "|"
for i, cell_data in enumerate(row_data):
cell = str(cell_data).ljust(col_width[i])
row = row + " " + cell + " |"

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.

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

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