Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
merged 8 commits into from
Oct 30, 2022

Conversation


@classmethod
def advance(cls, idempotency_key: str | None = None, **params: Any) -> Self: ...
def advance(self, idempotency_key: str | None = None, **params: Any) -> Self: ...
Copy link
Contributor Author

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)

@github-actions

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: ...
Copy link
Member

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.

Copy link
Contributor Author

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!

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@sbdchd
Copy link
Contributor Author

sbdchd commented Oct 29, 2022

hmm having some issues getting the stub test to ignore test clocks:

/tmp/tmpmdyv09e6/bin/pip install stripe[]==3.5.* mypy==0.982
MYPYPATH=/home/runner/work/typeshed/typeshed/stubs/stripe /tmp/tmpmdyv09e6/bin/python -m mypy.stubtest --custom-typeshed-dir /home/runner/work/typeshed/typeshed --ignore-missing-stub stripe --allowlist /home/runner/work/typeshed/typeshed/stubs/stripe/@tests/stubtest_allowlist.txt

error: stripe.api_resources.test_helpers.test_clock.TestClock.advance is inconsistent, stub is a classmethod but runtime is not
Stub: at line 11 in file /home/runner/work/typeshed/typeshed/stubs/stripe/stripe/api_resources/test_helpers/test_clock.pyi
def [Self] (cls: Type[Self`-1], idempotency_key: Union[builtins.str, None] =, **params: Any) -> Self`-1
Runtime: at line 19 in file /tmp/tmpmdyv09e6/lib/python3.9/site-packages/stripe/util.py
<function TestClock.advance at 0x7f36729bbdc0>

error: stripe.api_resources.test_helpers.test_clock.TestClock.advance is inconsistent, stub argument "idempotency_key" differs from runtime argument "self"
Stub: at line 11 in file /home/runner/work/typeshed/typeshed/stubs/stripe/stripe/api_resources/test_helpers/test_clock.pyi
def [Self] (cls: Type[Self`-1], idempotency_key: Union[builtins.str, None] =, **params: Any) -> Self`-1
Runtime: at line 19 in file /tmp/tmpmdyv09e6/lib/python3.9/site-packages/stripe/util.py
def (self, idempotency_key=None, **params)

error: stripe.api_resources.test_helpers.test_clock.TestClock.advance is inconsistent, stub argument "idempotency_key" has a default value but runtime argument does not
Stub: at line 11 in file /home/runner/work/typeshed/typeshed/stubs/stripe/stripe/api_resources/test_helpers/test_clock.pyi
def [Self] (cls: Type[Self`-1], idempotency_key: Union[builtins.str, None] =, **params: Any) -> Self`-1
Runtime: at line 19 in file /tmp/tmpmdyv09e6/lib/python3.9/site-packages/stripe/util.py
def (self, idempotency_key=None, **params)

error: stripe.api_resources.test_helpers.test_clock.TestClock.advance is inconsistent, stub does not have argument "idempotency_key"
Stub: at line 11 in file /home/runner/work/typeshed/typeshed/stubs/stripe/stripe/api_resources/test_helpers/test_clock.pyi
def [Self] (cls: Type[Self`-1], idempotency_key: Union[builtins.str, None] =, **params: Any) -> Self`-1
Runtime: at line 19 in file /tmp/tmpmdyv09e6/lib/python3.9/site-packages/stripe/util.py
def (self, idempotency_key=None, **params)

Found 4 errors (checked 151 modules)

To fix "unused allowlist" errors, remove the corresponding entries from /home/runner/work/typeshed/typeshed/stubs/stripe/@tests/stubtest_allowlist.txt

stripe... fail

@@ -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
Copy link
Collaborator

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.

stubs/stripe/@tests/stubtest_allowlist.txt Outdated Show resolved Hide resolved
stubs/stripe/@tests/stubtest_allowlist.txt Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@sbdchd sbdchd changed the title add(stripe): test clocks resource stripe: test clocks resource Oct 29, 2022
@sbdchd sbdchd requested a review from JelleZijlstra October 30, 2022 23:19
@JelleZijlstra JelleZijlstra merged commit 1f191a6 into python:master Oct 30, 2022
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.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.