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

28 is leap year #47

Merged
merged 15 commits into from
Jan 8, 2025
Merged

28 is leap year #47

merged 15 commits into from
Jan 8, 2025

Conversation

Khusro-S
Copy link
Member

@Khusro-S Khusro-S commented Dec 29, 2024


name: solution review
about: A template PR for code review with a checklist

Behavior

Files

  • The file name describes the function's behavior
  • There is a module docstring in the function file
  • The test file's name matches the function file name -
    /tests/test_file_name.py
  • There is a module docstring in the tests file

Unit Tests

  • The test class has a helpful name in PascalCase
  • The test class has a docstring
  • Every unit test has
    • A helpful name
    • A clear docstring
    • Only one assertion
    • There is no logic in the unit test
  • All tests pass
  • There are tests for defensive assertions
  • There are tests for boundary cases

Function Docstring

  • The function's behavior is described
  • The function's arguments are described:
    • Type
    • Purpose
    • Other assumptions (eg. if it's a number, what's the expected range?)
  • The return value is described
    • Type
    • Other assumptions are documented
  • The defensive assertions are documented using Raises:
    • Each assumption about an argument is checked with an assertion
    • Each assertion checks for only one assumption about the argument
  • Include 3 or more (passing!) doctests

The Function

  • The function's name describes it's behavior
  • The function's name matches the file name
  • The function has correct type annotations

Strategy

Do's

  • Variable names help to understand the strategy
  • Any comments are clear and describe the strategy
  • Lines of code are spaced to help show different stages of the strategy

Don'ts

  • The function's strategy is not described in the documentation
  • Comments explain the strategy, not the implementation
  • The function does not have more comments than code
    • If it does, consider finding a new strategy or a simpler implementation

Implementation

  • The code passes the formatting checks
  • The code passes all Ruff linting checks
  • The code has no (reasonable) Pylint errors
    • In code review, you can decide when fixing a Pylint error is helpful and
      when it's too restricting.
  • Variables are named with snake_case
  • Variable names are clear and helpful
  • The code follows the strategy as simply as possible
  • The implementation is as simple as possible given the strategy
  • The code includes defensive assertions
  • Defensive assertions include as little logic as possible

@Khusro-S Khusro-S requested a review from YonatanBest December 29, 2024 18:11
@Khusro-S Khusro-S self-assigned this Dec 29, 2024
@Khusro-S Khusro-S linked an issue Dec 29, 2024 that may be closed by this pull request
Copy link

@Mohamed-Elnageeb Mohamed-Elnageeb left a comment

Choose a reason for hiding this comment

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

Nice solution! I appreciate how compact it is, although some code norms might consider it less readable. However, I think it works well. The tests pass all the checklist requirements and are thorough and well-rounded. Great job! I have only highlighted a few small changes.

solutions/is_leap_year.py Outdated Show resolved Hide resolved
solutions/tests/test_is_leap_year.py Outdated Show resolved Hide resolved
solutions/is_leap_year.py Outdated Show resolved Hide resolved
YonatanBest
YonatanBest previously approved these changes Dec 30, 2024
Copy link

@YonatanBest YonatanBest left a comment

Choose a reason for hiding this comment

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

Great job! They passed all the ci checks, and everything seems correct for me. But could you change Created on XX XX XX to specific date?

@Khusro-S
Copy link
Member Author

I'll make these corrections soon, thanks for the feedback 🙌

@Khusro-S
Copy link
Member Author

Khusro-S commented Jan 1, 2025

Thank you both @YonatanBest and @Mohamed-Elnageeb. I made all the suggested changes and corrections 🙌.
Kindly review the changes one last time to make sure I didnt miss anything this time 😅 .

YonatanBest
YonatanBest previously approved these changes Jan 2, 2025
Copy link

@YonatanBest YonatanBest left a comment

Choose a reason for hiding this comment

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

They passed all the ci checks. And They are well written. Great Job!

@Khusro-S
Copy link
Member Author

Khusro-S commented Jan 2, 2025

They passed all the ci checks. And They are well written. Great Job!

Thank you 🙌

Copy link

@Mohamed-Elnageeb Mohamed-Elnageeb left a comment

Choose a reason for hiding this comment

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

I see no changes needed. Good job!

Copy link

@Mohamed-Elnageeb Mohamed-Elnageeb left a comment

Choose a reason for hiding this comment

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

I see no changes needed. Good job!

@Zeinab15 Zeinab15 self-requested a review January 3, 2025 13:06
Copy link

@Zeinab15 Zeinab15 left a comment

Choose a reason for hiding this comment

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

Well done @Khusro-S , just a few suggestions

Copy link

@Zeinab15 Zeinab15 left a comment

Choose a reason for hiding this comment

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

The code is well-structured with good test coverage, but there are a few areas for improvement:

Error Handling: Replace AssertionError with more specific exceptions like TypeError for invalid types and ValueError for non-positive years.
Test Coverage: Consider adding a test for the year 0 to raise a ValueError, as it's an invalid input.

solutions/is_leap_year.py Show resolved Hide resolved
solutions/tests/test_is_leap_year.py Show resolved Hide resolved
@Khusro-S
Copy link
Member Author

Khusro-S commented Jan 5, 2025

The code is well-structured with good test coverage, but there are a few areas for improvement:

Error Handling: Replace AssertionError with more specific exceptions like TypeError for invalid types and ValueError for non-positive years. Test Coverage: Consider adding a test for the year 0 to raise a ValueError, as it's an invalid input.

Yeah, you’re right, that’s a good point and definitely best practice. I’ll make those changes in a bit. Thank you 🎉

… function.

- Replaced assert statements with specific error handling (TypeError and ValueError).
- Updated test cases to check for the new errors:
-- TypeError for non-integer inputs (string, None, float).
-- ValueError for negative year inputs.
Copy link

@Zeinab15 Zeinab15 left a comment

Choose a reason for hiding this comment

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

Good job @Khusro-S

Copy link

@YonatanBest YonatanBest left a comment

Choose a reason for hiding this comment

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

Great job!

solutions/is_leap_year.py Show resolved Hide resolved
@Khusro-S Khusro-S merged commit a5dc335 into main Jan 8, 2025
10 checks passed
@Khusro-S Khusro-S deleted the 28-is_leap_year branch January 8, 2025 09:05
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.

Is_Leap_Year
4 participants