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

Fix check_contracts typings #962

Merged

Conversation

ChristopherLi05
Copy link
Contributor

@ChristopherLi05 ChristopherLi05 commented Sep 27, 2023

Motivation and Context

Addresses #961

Your Changes

Description:

  • I added Class = TypeVar("Class", bound=type) as a wildcard to match classes
  • I created 2 overload methods for check_contracts that better reflects how the function works

Type of change (select all that apply):

  • Bug fix (non-breaking change which fixes an issue)

Testing

I tested the following code and PyCharm doesn't show Cannot find reference '__init__' in '(...)->Any'

from python_ta.contracts import check_contracts


@check_contracts
class Foo:
    def __init__(self):
        self.a = 5


@check_contracts
class Bar(Foo):
    def __init__(self):
        Foo.__init__(self)

Checklist

  • I have performed a self-review of my own code.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported on Coveralls.
  • I have updated the CHANGELOG.md file.

Copy link
Contributor

@david-yz-liu david-yz-liu left a comment

Choose a reason for hiding this comment

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

@ChristopherLi05 thanks for creating this pull request. Great work! Two comments:

  1. You should do a merge/rebase from master; when you do, you'll see in the CHANGELOG that there's a "Bug fixes" section under [unreleased], which is where you should put your new entry. (Version 2.6.2 has already been released.)
  2. Please add your name to the list of contributors in the README (assuming you want to be recognized!).

@ChristopherLi05
Copy link
Contributor Author

Fixed! 😊

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 6444132922

  • 7 of 7 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 94.593%

Totals Coverage Status
Change from base Build 6444053842: 0.03%
Covered Lines: 3394
Relevant Lines: 3588

💛 - Coveralls

@david-yz-liu david-yz-liu merged commit e69e76a into pyta-uoft:master Oct 8, 2023
@david-yz-liu david-yz-liu added this to the v2.6.3 milestone Oct 8, 2023
david-yz-liu pushed a commit that referenced this pull request Oct 9, 2023
@ChristopherLi05 ChristopherLi05 deleted the check_contract_typings branch October 10, 2023 18:15
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.

3 participants