Skip to content

Conversation

xavdid-stripe
Copy link
Member

@xavdid-stripe xavdid-stripe commented Sep 12, 2025

Why?

Mutable default function arguments are a classic python footgun. Though we haven't gotten any issues related to this, it's a bug waiting to happen.

What?

  • add linter to catch use of mutable default args
  • set param defaults to None instead of {}. The function(s) we're calling also take optional params, so we'll leave it up to them to pick a default
  • similar manual fixes
  • add new linter to catch these in the future

See Also

DEVSDK-2139

Changelog

  • Service methods now correctly set None as the default function argument instead of {}

@xavdid-stripe xavdid-stripe requested a review from a team as a code owner September 12, 2025 18:28
@xavdid-stripe xavdid-stripe requested review from jar-stripe and prathmesh-stripe and removed request for a team and jar-stripe September 12, 2025 18:28
@prathmesh-stripe
Copy link
Contributor

This shouldn't be a breaking change, since we weren't modifying these values internally. But, it's worth calling out in the changelog.

We can get rid of this line from the changelog.

@xavdid-stripe xavdid-stripe enabled auto-merge (squash) September 18, 2025 20:50
@xavdid-stripe xavdid-stripe merged commit b6bf4a4 into master Sep 18, 2025
15 checks passed
@xavdid-stripe xavdid-stripe deleted the fix-mutable-arguments branch September 18, 2025 20:54
helenye-stripe pushed a commit that referenced this pull request Sep 22, 2025
* Update generated code for v1868 and 2025-07-30.basil (#1541)

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>

* Bump version to 12.4.0

* Introduce V1 namespaces in StripeClient (#1549)

* Introduced V1 namespaces

* Updated migration guide link

* Import available http libraries more efficiently (#1553)

* replace import stragety, fix some tests

[skip ci]

* wip fixing tests

[skip ci]

* [claude] fix tests

* formatting

* test cleanup

* tests are fast

* final cleanup

* remove comment

* remove accidential files

* tweak import logic

* Update generated code for v1932 and 2025-08-27.basil (#1544)

Co-authored-by: Stripe OpenAPI <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>

* Add section on private preview SDKs in readme (#1554)

* Bump version to 12.5.0

* Add private-preview branch to CI workflow triggers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: paginate backwards if `starting_after == None` (#1563)

This fixes the case where `starting_after` is present in
`_retrieve_params` but is `None` so that the `auto_paging_iter`
correctly paginates backwards.

closes #1562

* Bump version to 12.5.1

* add support for v2 deleted objects (#1543)

* add support for v2 deleted objects

* revert event destination return type

* ⚠️ Build SDK w/ V2 OpenAPI spec (#1565)

* generate w/ v2 openapi spec

* gen again

* gen

* Updated stripeclient snippets in Readme.md (#1528)

* Don't use mutable default arguments (#1570)

* generate default assignments

* add mutable args linter and fix errors

* type generated args more accurately

* only initialize optional params when needed

* generate private-preview

---------

Co-authored-by: stripe-openapi[bot] <105521251+stripe-openapi[bot]@users.noreply.github.com>
Co-authored-by: Ramya Rao <ramya@stripe.com>
Co-authored-by: prathmesh-stripe <165320323+prathmesh-stripe@users.noreply.github.com>
Co-authored-by: Ramya Rao <100975018+ramya-stripe@users.noreply.github.com>
Co-authored-by: Michael Broshi <mbroshi@stripe.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Ryan Causey <ryan.causey@munipal.io>
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