Skip to content

3. Рамазанова Дарина Наимовна 614 - #181

Open
darinaramazanova wants to merge 11 commits into
python-department:mainfrom
darinaramazanova:feature/task-3
Open

darinaramazanova wants to merge 11 commits into
python-department:mainfrom
darinaramazanova:feature/task-3

Conversation

@darinaramazanova

Copy link
Copy Markdown

No description provided.

Comment thread src/part3/utils.py
# measured per call from the data (see the function).
# TODO: задайте заголовки столбцов таблицы
TABLE_HEADERS: Final[tuple[str, ...]] = ()
TABLE_HEADERS: Final[tuple[str, ...]] = ("ID", "name", "price", "quatity")

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.

Опечатка в слове quantity. Из-за этого часть тестов не пройдена

Comment thread src/part3/run_admin.py

from .crud import ( # noqa: F401
create_product,
delete_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.

Нарушение критерия M2. Импортированная функция delete_product ни разу не используется в этом модуле.

Минус 0.5 балла

Comment thread src/part3/run_admin.py
# TODO: реализуйте функцию
return False
parts = line.split()
if not parts:

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.

Для разбора команд следовало использовать конструкцию match-case, т.к. эта конструкция идеально подходит для сопоставления шаблонов. Из-за использования ветвления получилось большое количество дублирования логики разбора команд (проверка количества слов + применение срезов). Это нарушение критерия S1. Минус балл

Comment thread src/part3/run_admin.py
command = parts[0]
if command == "help":
show_help()
elif command == "exit":

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/part3/run_admin.py
return False
elif command == "show":
print(get_storage_str_representation(storage))
elif command == "read" or command == "delete":

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.

Вы используете один и тот же обработчик для команд read и delete. При этом в самом обработчике вы вызываете только функцию read_product, а команда delete_product нигде не выполняется. Отсюда ошибка, т.к. ваша CLI не умеет удалять продукты из БД.

Следовало разделить обработку этих команд.

Comment thread src/part3/run_admin.py
return True
name = " ".join(parts[1:-2])
price = Decimal(parts[-2])
quantity = int(parts[-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/run_admin.py
updated = update_product(storage, product_id, (name, price, quantity))
print_result(updated)
else:
print(f"'{line}' 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.

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

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

Comment thread src/part3/utils.py
header_cells = [f"{header:<{widths[i]}}" for i, header in enumerate(TABLE_HEADERS)]
header_line = "| " + " | ".join(header_cells) + " |"
separator_cells = ["-" * (widths[i] + 2) for i in range(len(TABLE_HEADERS))]
separator_line = "|" + "|".join(separator_cells) + "|"

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 балла

Comment thread src/part3/utils.py
# TODO: при необходимости добавьте свои вспомогательные функции


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

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