Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kaliv0
Copy link
Owner

@kaliv0 kaliv0 commented Dec 6, 2024

Summary by Sourcery

Add an Interface decorator to enforce method presence and signature compliance, along with tests to validate its functionality. Enhance the CI workflow with a line-length configuration and update project metadata in pyproject.toml.

New Features:

  • Introduce an Interface decorator to enforce method presence and signature compliance in classes.

Enhancements:

  • Add utility function not_raises to simplify exception handling in tests.

CI:

  • Update CI workflow to include a line-length configuration for code formatting.

Documentation:

  • Update pyproject.toml with additional metadata including keywords and repository URL.

Tests:

  • Add comprehensive tests for the new Interface decorator, covering various inheritance scenarios and method signature validations.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 6, 2024

Reviewer's Guide by Sourcery

This PR introduces an Interface decorator implementation along with its supporting test cases. The implementation allows for interface-like behavior in Python, enforcing method implementation and signature matching at class definition time.

Class diagram for the new Interface and InterfaceError classes

classDiagram
    class InterfaceError {
        <<Exception>>
    }

    class Interface {
        - required_methods
        + __init__(*klass)
        + __call__(klass)
        + _get_methods(*klass) static
    }

    Interface --> InterfaceError : raises
Loading

File-Level Changes

Change Details Files
Added Interface decorator implementation with validation logic
  • Created InterfaceError exception class
  • Implemented Interface decorator class with method validation
  • Added support for multiple interface inheritance
  • Added method signature validation using inspect module
  • Implemented helper method to extract class methods
pypermissive/decorators.py
Added comprehensive test suite for Interface functionality
  • Added tests for basic interface implementation
  • Added tests for interface inheritance scenarios
  • Added tests for multiple interface implementation
  • Added tests for method signature validation
  • Created test utility for negative test cases
tests/test_decorators.py
tests/conftest.py
tests/util.py
Updated project metadata and configuration
  • Bumped version from 1.0.0 to 1.0.1
  • Added repository information and keywords
  • Updated package configuration
  • Removed twine dependency
  • Modified CI workflow formatting configuration
pyproject.toml
.github/workflows/ci.yml

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

@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 @kaliv0 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding documentation for the new interface validation feature
  • This change introduces a new feature (interface validation) which typically warrants a minor version bump (1.1.0) rather than a patch version bump (1.0.1) according to semver
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kaliv0 kaliv0 force-pushed the add-interfaces branch 2 times, most recently from abbb789 to 93568c1 Compare December 6, 2024 13:40
@kaliv0 kaliv0 merged commit 97395a7 into main Dec 6, 2024
2 checks passed
@kaliv0 kaliv0 deleted the add-interfaces branch December 6, 2024 13:56
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