Skip to content

fix: Re-export SDK imports from every module - #187

Merged
davidgrayston-paddle merged 5 commits into
mainfrom
fix/module-reexports
Nov 24, 2026
Merged

davidgrayston-paddle merged 5 commits into
mainfrom
fix/module-reexports

Conversation

@davidgrayston-paddle

@davidgrayston-paddle davidgrayston-paddle commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

With the py.typed marker added in #180, type checkers only treat a name as public from a module if the module re-exports it. Before that, they didn't apply this rule to the SDK, so any name a module imported could be imported from it. On main, 2,457 such imports now fail with pyright's default settings and with mypy --strict, for example:

from paddle_billing.Client import CustomersClient
from paddle_billing.Entities.Subscription import SubscriptionStatus
from paddle_billing.Entities.Subscriptions.SubscriptionItem import SubscriptionItemStatus

Changes

  • Every top-level SDK import in every module that isn't an __init__.py now uses the Name as Name form (including the three relative imports), the same change feat: Add py.typed marker and fix type annotations #180 made to __init__.py files. The diff is mechanical: apart from the seven modules in the next two points, every changed module has the same syntax tree as on main once the as aliases are removed, so runtime behaviour is unchanged.
  • UpdateCheckoutUrl.py imports Undefined again. fix: Require default_url when updating the checkout URL #183 removed it once default_url became required, so from paddle_billing.Resources.Settings.Operations.UpdateCheckoutUrl import Undefined raises ImportError on main. It's kept the same way feat: Add py.typed marker and fix type annotations #180 kept ReportType and ReportFilter in CreateReport.py.
  • Six renamed imports are now public too: NotificationEntity in Entities/Event.py, Entities/Notifications/NotificationEvent.py and Entities/SimulationRunEvent.py, PriceIncludes and ProductIncludes in ListPrices.py and ListProducts.py, and PaymentMethodDeletedEntity in Notifications/Events/PaymentMethodDeleted.py. Type checkers never treat a renamed import as public, and __all__ would change what import * returns, so each is imported under a private name and assigned to the public one, for example PriceIncludes = _PriceIncludes. It's the same class, and import * from these modules gives the same names as on main.
  • tests/Unit/test_PackageExports.py now checks every module: a plain SDK import, or a renamed one whose name doesn't start with _, anywhere in the package fails the test. It also looks inside module-level if and try blocks, except if TYPE_CHECKING:.

What this makes public

This is deliberate: every name a module imports from the SDK is now public from that module, including internal helpers such as Options and ResponseParser from paddle_billing.Client. All of these could be imported before py.typed, so this keeps that behaviour rather than choosing a smaller set. Removing one of these imports later is a breaking change for type checkers, so narrowing what's public is left for a major release.

Re-exporting from paddle_billing.Client is a convenience: each resource client can also be imported from the module that defines it, for example from paddle_billing.Resources.Customers.CustomersClient import CustomersClient.

Not changed

  • Imports under TYPE_CHECKING, which aren't importable at runtime.
  • Standard library and third-party names a module imports, such as datetime or Any.

How this was checked

Every SDK name importable from every module of the released 1.18.0 package was listed at runtime: 3,850 names across 876 modules. An import of each was then run and type-checked against main and against this branch:

Imports that fail at runtime pyright (default) errors mypy --strict errors
main 1 (Undefined) 2,457 2,457
this branch 0 0 0

Tests, black, flake8 and mypy paddle_billing pass.

No changelog entry: this keeps imports working that worked in 1.18.0, so it's part of the unreleased py.typed change.

@davidgrayston-paddle davidgrayston-paddle changed the title fix: Re-export imported names from Client and entity modules fix: Re-export SDK imports from every module Nov 24, 2026
mikeymike
mikeymike previously approved these changes Nov 24, 2026
@davidgrayston-paddle
davidgrayston-paddle merged commit bca6690 into main Nov 24, 2026
6 checks passed
@davidgrayston-paddle
davidgrayston-paddle deleted the fix/module-reexports branch November 24, 2026 13:36

This branch was successfully deployed

1 active deployment
dev — a017c6c3 Deployed Nov 24, 2026 by davidgrayston-paddle via lint #424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants