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

Kyu6: Valid Braces #542

Merged
merged 21 commits into from
Nov 28, 2024
Merged

Kyu6: Valid Braces #542

merged 21 commits into from
Nov 28, 2024

Conversation

ikostan
Copy link
Member

@ikostan ikostan commented Nov 25, 2024

Summary by Sourcery

Add a new feature to validate strings of braces with the 'valid_braces' function, including comprehensive unit tests and documentation.

New Features:

  • Implement the 'valid_braces' function to check the validity of a string of braces.

Documentation:

  • Add a README file for the 'Valid Braces' feature, explaining the function's purpose and providing examples.

Tests:

  • Introduce unit tests for the 'valid_braces' function to ensure it correctly validates strings of braces.

Copy link

codeclimate bot commented Nov 25, 2024

Code Climate has analyzed commit 6b7111b and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 89.9% (0.0% change).

View more on Code Climate.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.92%. Comparing base (8762a9f) to head (6b7111b).
Report is 8 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #542      +/-   ##
==========================================
+ Coverage   89.88%   89.92%   +0.04%     
==========================================
  Files         169      170       +1     
  Lines        2541     2552      +11     
==========================================
+ Hits         2284     2295      +11     
  Misses        257      257              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

kyu_6/valid_braces/valid_braces.py Outdated Show resolved Hide resolved
kyu_6/valid_braces/valid_braces.py Outdated Show resolved Hide resolved
kyu_6/valid_braces/valid_braces.py Outdated Show resolved Hide resolved
kyu_6/valid_braces/valid_braces.py Outdated Show resolved Hide resolved
kyu_6/valid_braces/valid_braces.py Show resolved Hide resolved
kyu_6/valid_braces/valid_braces.py Outdated Show resolved Hide resolved
./kyu_6/valid_braces/valid_braces.py:18:1: E302 expected 2 blank lines, found 1
Unnecessary elif after return
Copy link
Contributor

sourcery-ai bot commented Nov 28, 2024

Reviewer's Guide by Sourcery

This PR implements a solution for validating properly matched braces in a string. The implementation uses a dictionary-based approach to match opening and closing braces, with additional validation logic for string length and bracket positioning.

Class diagram for Valid Braces Function

classDiagram
    class valid_braces {
        +valid_braces(string: str) bool
    }
    note for valid_braces "This function checks if the order of braces in a string is valid."
Loading

File-Level Changes

Change Details Files
Implementation of brace validation algorithm
  • Created a dictionary mapping opening braces to closing braces
  • Added validation for even string length
  • Implemented checks for proper bracket positioning in first/second half of string
  • Added logic to handle both adjacent and split matching pairs
kyu_6/valid_braces/valid_braces.py
Added comprehensive test suite for brace validation
  • Created test cases for various valid and invalid brace combinations
  • Added test data covering simple, nested, and mixed brace patterns
  • Included allure test decorators for test organization and reporting
kyu_6/valid_braces/test_valid_braces.py
Added documentation and problem description
  • Added detailed problem description with examples
  • Included link to original kata source
kyu_6/valid_braces/README.md
Updated test categorization
  • Changed suite category from 'Advanced Language Features' to 'Fundamentals'
kyu_6/unique_in_order/test_unique_in_order.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ikostan - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using a stack-based approach for validating braces to simplify the logic and improve efficiency.
  • Add more test cases to cover edge cases, such as deeply nested braces, to ensure robustness.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Hi @ikostan! 👋

@sourcery-ai is now installed on this repository.

We found this recent PR of yours and reviewed it to show you what Sourcery can do.

If you want to review another PR, just comment with @sourcery-ai review

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

kyu_6/valid_braces/valid_braces.py Show resolved Hide resolved
kyu_6/valid_braces/test_valid_braces.py Show resolved Hide resolved
kyu_6/valid_braces/valid_braces.py:30: error: Incompatible types in assignment (expression has type "int | None", variable has type "int")  [assignment]
@ikostan ikostan merged commit 96fb464 into master Nov 28, 2024
24 checks passed
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.

1 participant