Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #1251

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #1251

wants to merge 3 commits into from

Conversation

bashyrov
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Thank you for your hard work on this project! 😊 While your implementation is mostly correct, there are a few critical issues that need to be addressed to fully meet the task requirements:

  1. Error Messages: The exceptions in the visit_cafe method lack descriptive messages. It's important to provide clear feedback when exceptions are raised, such as 'Visitor is not vaccinated.' for NotVaccinatedError.

  2. Imports: The use of relative imports in your code should be replaced with absolute imports, like from app.cafe import Cafe, to comply with the checklist.

  3. Abstract Method: The NotVaccinatedError class incorrectly uses an abstract method for __str__. This should be removed since it's not intended to be overridden.

These issues are crucial as they affect the clarity and maintainability of your code. Please address them, and feel free to reach out if you need any help. Keep up the great work! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

app/cafe.py Outdated

def visit_cafe(self, visitor: dict) -> Any:
if "vaccine" not in visitor:
raise NotVaccinatedError

Choose a reason for hiding this comment

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

The NotVaccinatedError should be raised with a descriptive message. According to the checklist, you should provide a message when raising exceptions. For example: raise NotVaccinatedError('Visitor is not vaccinated.').

app/cafe.py Outdated
if "vaccine" not in visitor:
raise NotVaccinatedError
elif visitor["vaccine"]["expiration_date"] < datetime.date.today():
raise OutdatedVaccineError

Choose a reason for hiding this comment

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

The OutdatedVaccineError should be raised with a descriptive message. According to the checklist, you should provide a message when raising exceptions. For example: raise OutdatedVaccineError('Visitor's vaccine is expired.').

app/cafe.py Outdated
elif visitor["vaccine"]["expiration_date"] < datetime.date.today():
raise OutdatedVaccineError
elif not visitor["wearing_a_mask"]:
raise NotWearingMaskError

Choose a reason for hiding this comment

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

The NotWearingMaskError should be raised with a descriptive message. According to the checklist, you should provide a message when raising exceptions. For example: raise NotWearingMaskError('Visitor is not wearing a mask.').

app/cafe.py Outdated
Comment on lines 3 to 5
from .errors import (NotVaccinatedError,
OutdatedVaccineError,
NotWearingMaskError)

Choose a reason for hiding this comment

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

Use absolute imports instead of relative imports as per the checklist. Change to: from app.errors import NotVaccinatedError, OutdatedVaccineError, NotWearingMaskError.

app/errors.py Outdated
Comment on lines 10 to 12
@abstractmethod
def __str__(self) -> str:
return "NotVaccinatedError"

Choose a reason for hiding this comment

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

The __str__ method in NotVaccinatedError should not be abstract since it is not intended to be overridden in subclasses. Remove the @abstractmethod decorator.

app/errors.py Outdated

@abstractmethod
def __str__(self) -> str:
return "NotVaccinatedError"

Choose a reason for hiding this comment

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

The __str__ method should provide a more descriptive error message. Consider returning a message like: 'Visitor is not vaccinated.'

app/errors.py Outdated

class OutdatedVaccineError(VaccineError):
def __str__(self) -> str:
return "OutdatedVaccineError"

Choose a reason for hiding this comment

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

The __str__ method should provide a more descriptive error message. Consider returning a message like: 'Visitor's vaccine is expired.'

app/errors.py Outdated

class NotWearingMaskError(Exception):
def __str__(self) -> str:
return "NotWearingMaskError"

Choose a reason for hiding this comment

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

The __str__ method should provide a more descriptive error message. Consider returning a message like: 'Visitor is not wearing a mask.'

app/main.py Outdated
Comment on lines 1 to 2
from .cafe import Cafe
from .errors import NotWearingMaskError, VaccineError

Choose a reason for hiding this comment

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

Use absolute imports instead of relative imports as per the checklist. Change to: from app.cafe import Cafe and from app.errors import NotWearingMaskError, VaccineError.

Comment on lines +11 to +12
except VaccineError:
return "All friends should be vaccinated"

Choose a reason for hiding this comment

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

Consider handling NotVaccinatedError and OutdatedVaccineError separately to provide more specific feedback. For example, you could return different messages for unvaccinated friends and those with expired vaccines.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

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

Review Summary

Great job on addressing most of the previous issues! 🎉 The implementation in your code is mostly correct, and you've made significant improvements. Here are some key points and areas for further enhancement:

  1. Error Messages: You've successfully added descriptive error messages in the visit_cafe method, which provides clear feedback when exceptions are raised. This is a crucial aspect of user experience and debugging.

  2. Imports: While your code uses absolute imports, which is a step in the right direction, there are still some inconsistencies. Ensure that all import statements are using absolute paths as per the checklist requirements. For example, change from app.errors import NotWearingMaskError, VaccineError to from errors import NotWearingMaskError, VaccineError.

  3. Abstract Method: The issue with the abstract method in the NotVaccinatedError class has been resolved, which is excellent. This ensures that your exception classes are correctly implemented.

  4. VaccineError Parent Class: The VaccineError class is correctly defined and used as a parent class for NotVaccinatedError and OutdatedVaccineError, which is a good practice for handling exceptions.

Overall, your code meets the task requirements and constraints. Although there are minor issues with import statements, the decision to approve your pull request is made to help you move forward with your learning journey. Please review the comments and make the necessary adjustments to improve your code. Remember, addressing these issues will enhance your coding skills and prevent similar problems in the future. Keep up the good work and continue to learn from your experiences! 🚀

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -0,0 +1,22 @@
import datetime
from typing import Any
from app.errors import (

Choose a reason for hiding this comment

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

The import statement should use absolute imports instead of relative imports. Change from app.errors import to from errors import to comply with the checklist.

@@ -1 +1,19 @@
# write your code here
from app.cafe import Cafe

Choose a reason for hiding this comment

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

The import statement should use absolute imports instead of relative imports. Change from app.cafe import Cafe to from cafe import Cafe to comply with the checklist.

@@ -2,0 +1,19 @@
from app.cafe import Cafe
from app.errors import NotWearingMaskError, VaccineError

Choose a reason for hiding this comment

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

The import statement should use absolute imports instead of relative imports. Change from app.errors import NotWearingMaskError, VaccineError to from errors import NotWearingMaskError, VaccineError to comply with the checklist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants