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

Add support for passing full objects instead of IDs to custom methods #601

Merged
merged 1 commit into from Aug 6, 2019

Conversation

ob-stripe
Copy link
Contributor

r? @brandur-stripe
cc @stripe/api-libraries

See my comment here for context around the issue this fixes.

In Python, instance methods are really functions that accept the instance as their first argument, e.g.:

class Foo(object):
    def do(self):
        print("Hi!")

foo = Foo()

# the following are equivalent
foo.do()
Foo.do(foo)

The hack we introduced in #543 to support declaring instance methods and class methods with the same name broke support for the second syntax. This PR restores support for the second syntax by explicitly checking if the method was invoked with an instance as its first argument.

Fixes #597.

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

Great work on this PR — thank you for the comments (made things very clear), and thank you for the tests (let's me assume that this actually works ;).

LGTM.

@stripe-ci stripe-ci assigned ob-stripe and unassigned brandur-stripe Aug 6, 2019
@ob-stripe ob-stripe merged commit 72854b3 into master Aug 6, 2019
@ob-stripe ob-stripe deleted the ob-fix-597 branch August 6, 2019 19:58
@ob-stripe
Copy link
Contributor Author

Released as 2.33.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.51.0 -> 2.3.3 Upgrade] TypeError: quote_from_bytes() expected bytes
3 participants