Skip to content

add mypy support#115

Open
vanschelven wants to merge 1 commit intochargebee:masterfrom
vanschelven:mypy
Open

add mypy support#115
vanschelven wants to merge 1 commit intochargebee:masterfrom
vanschelven:mypy

Conversation

@vanschelven
Copy link
Copy Markdown

@vanschelven vanschelven commented Feb 12, 2026

  • 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 the following errors & problems:

  • Module "chargebee" does not explicitly export attribute "Chargebee"
  • Skipping analyzing "chargebee": module is installed, but missing library stubs or py.typed marker
  • All chargebee results types being interpreted as Any despite 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.

* 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-io
Copy link
Copy Markdown

snyk-io bot commented Feb 12, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@vanschelven
Copy link
Copy Markdown
Author

vanschelven commented Feb 18, 2026

@cb-alish kindly asking to approve the workflow; and (if you have the time) to review this 😄

@cb-alish
Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown

@hivel-marco hivel-marco bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 from chargebee.models.enums and all model operation classes (e.g., Addon, Customer, Subscription) to make exports explicit and type-checker friendly.
  • Defines a large, explicit __all__ list in chargebee/__init__.py to clearly specify the public API, including models, enums, errors, and internal modules intended for export.
  • Adds a py.typed file 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 at chargebee.*, 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 from chargebee may fail or confuse consumers.
  • Downstream users relying on implicit or undocumented attributes from chargebee might 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.

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