Conversation
* Added chargebee/py.typed * Copy/pasted the import statements from chargebee/models.py to __init__.py * Added all actually imported items to __all__. This avoids: * Module "chargebee" does not explicitly export attribute "Chargebee" * Skipping analyzing "chargebee": module is installed, but missing library stubs or py.typed marker Since there were already quite a few typing annotations this actually brings chargebee into a "works for me" status w.r.t. mypy usage.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
@cb-alish kindly asking to approve the workflow; and (if you have the time) to review this 😄 |
|
Hi @vanschelven, thanks for raising this PR! We actually use an SDK generator to generate our SDKs. We'll need to add mypy support through the generator so that these changes are automatically propagated in future releases. Please give us some time we'll get that added. In the meantime, feel free to join our Discord community. |
There was a problem hiding this comment.
PR Complexity Score: 1.9 - Trivial
View Breakdown
- Lines Changed: 528
- Files Changed: 2
- Complexity Added: 0
- Raw Score: 16.56
Overview
This PR refactors the chargebee package’s public API exports by removing the wildcard import from chargebee.models and replacing it with explicit imports for enums and model operation classes.
It introduces a comprehensive __all__ definition to clearly control what the top-level chargebee namespace exposes.
It also adds a py.typed marker file to signal that the package provides typing information to type checkers.
Key Changes
- Replaces
from chargebee.models import *with explicit imports of all enums fromchargebee.models.enumsand all model operation classes (e.g.,Addon,Customer,Subscription) to make exports explicit and type-checker friendly. - Defines a large, explicit
__all__list inchargebee/__init__.pyto clearly specify the public API, including models, enums, errors, and internal modules intended for export. - Adds a
py.typedfile to mark the distribution as typed (PEP 561), enabling downstream projects to leverage Chargebee’s type information.
Risks & Considerations
- Any symbol previously provided via
from chargebee.models import *but not now included in the explicit imports or__all__may no longer be available atchargebee.*, potentially breaking consumers relying on those names. - The
__all__list includes some names (e.g., error types, internal modules) that must continue to exist elsewhere in the package; if any are missing or renamed, importing fromchargebeemay fail or confuse consumers. - Downstream users relying on implicit or undocumented attributes from
chargebeemight experience type-checker or runtime import issues and should verify their imports against the new, explicit public API.
File-level change summary
| File | Change summary |
|---|---|
| chargebee/init.py | Replaces wildcard model import with explicit enum/model imports and introduces a detailed __all__ to define the public API surface. |
| chargebee/py.typed | Adds an empty py.typed marker file to declare the package as typed for static type checkers. |
chargebee/py.typedchargebee/models.py to __init__.py__all__.This avoids the following errors & problems:
Anydespite more rich information being available.Since there were already quite a few typing annotations this actually brings chargebee into a "works for me" status w.r.t. mypy usage.