-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
stripe: test clocks resource #9026
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
stripe: test clocks resource #9026
Conversation
|
||
@classmethod | ||
def advance(cls, idempotency_key: str | None = None, **params: Any) -> Self: ... | ||
def advance(self, idempotency_key: str | None = None, **params: Any) -> Self: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the api supports:
stripe.test_helpers.TestClock.advance(frozen_time=frozen_time)
and
clock = stripe.test_helpers.TestClock.create(frozen_time=frozen_time)
clock.advance(frozen_time=frozen_time)
This comment has been minimized.
This comment has been minimized.
OBJECT_NAME: Literal["test_helpers.test_clock"] | ||
|
||
@classmethod | ||
def advance(cls: type[Self], idempotency_key: str | None = ..., **params: Any) -> Self: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This weird thing Stripe does where the method is both an instance method and a class method is confusing, but what you currently have is invalid.
I think putting only a classmethod would produce correct types, because classmethods can also be called on instances. So I suggest removing the last line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thank you! removing the instance method worked like a charm!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
hmm having some issues getting the stub test to ignore test clocks:
|
@@ -1,5 +1,6 @@ | ||
# The following methods have custom classmethod decorators | ||
stripe\..*\.delete | ||
stripe\..*PaymentIntent\.confirm | ||
stripe\.api_resources\..*\.SearchableAPIResource\.search # Not defined on the actual class in v3, but expected to exist. | ||
stripe\.api_resources\..*\.SearchableAPIResource\.search_auto_paging_iter # Not defined on the actual class in v3, but expected to exist. | ||
stripe\..*TestClock\.advance |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the wildcard? Seems like stripe.api_resources.test_helpers.test_clock.TestClock.advance
would work.
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
based off: https://github.com/stripe/stripe-python/blob/16812ae9ff5b78d8f103c09da461e5569890d05f/stripe/api_resources/test_helpers/test_clock.py
and https://stripe.com/docs/api/test_clocks/advance?lang=python