-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
Solution #1251
Conversation
There was a problem hiding this 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:
-
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.'
forNotVaccinatedError
. -
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. -
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
from .errors import (NotVaccinatedError, | ||
OutdatedVaccineError, | ||
NotWearingMaskError) |
There was a problem hiding this comment.
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
@abstractmethod | ||
def __str__(self) -> str: | ||
return "NotVaccinatedError" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
from .cafe import Cafe | ||
from .errors import NotWearingMaskError, VaccineError |
There was a problem hiding this comment.
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
.
except VaccineError: | ||
return "All friends should be vaccinated" |
There was a problem hiding this comment.
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.
There was a problem hiding this 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:
-
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. -
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
tofrom errors import NotWearingMaskError, VaccineError
. -
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. -
VaccineError Parent Class: The
VaccineError
class is correctly defined and used as a parent class forNotVaccinatedError
andOutdatedVaccineError
, 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 ( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
No description provided.