-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Describe the Bug
When chartmogul-python is used in an environment with marshmallow>=4.0.0, it fails during schema serialization with the error AttributeError: 'Number' object has no attribute 'num_type'.
This is because Marshmallow deprecated fields.Number as a base class in version 3.24 and completely removed this functionality in version 4.0. The library currently uses fields.Number directly in its schemas (e.g., for MRR, ARR, and various metric fields), causing a hard crash.
This bug prevents projects that depend on chartmogul-python from upgrading to modern versions of Marshmallow, which can block other critical dependency upgrades and create a fragile environment.
Error Message
Traceback (most recent call last):
...
AttributeError: 'Number' object has no attribute 'num_type'
To Reproduce
Steps to reproduce the behavior:
- Create an environment with
marshmallow>=4.0.0and the current version ofchartmogul-python. - Attempt to load any data that would instantiate a
CustomerorMetricsschema.
A minimal code example:
import marshmallow
from chartmogul.api.customer import Customer
# This will fail with Marshmallow v4+
print(f"Using marshmallow version: {marshmallow.__version__}")
# This line raises the AttributeError because Customer._Schema
# directly instantiates fields.Number(), which is not allowed in v4.
customer_schema = Customer._Schema()Expected Behavior
The library should be compatible with Marshmallow v4.x and handle numeric fields without crashing, allowing it to be used in projects with modern dependency requirements.
Solution
A Pull Request has been created to resolve this issue. The fix replaces the deprecated fields.Number with the appropriate fields.Float and updates the dependency constraints in setup.py to officially support Marshmallow 4.x.
The complete fix, including updated tests and changelog, is available here: PR #114
This change is backward-compatible and resolves the critical incompatibility. Merging this PR would unblock users and align the library with the current Python data ecosystem.