Skip to content

Bug: Marshmallow 4.x Incompatibility causes AttributeError: 'Number' object has no attribute 'num_type' #115

@davidlacho

Description

@davidlacho

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:

  1. Create an environment with marshmallow>=4.0.0 and the current version of chartmogul-python.
  2. Attempt to load any data that would instantiate a Customer or Metrics schema.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions