Skip to content

Schema-level nullable flag #2080

@Dev-iL

Description

@Dev-iL

Is your feature request related to a problem? Please describe.
My use case is as follows:

  • I have several schemas which are subclasses of pa.DataFrameModel, where fields may or may not be nullable.
  • I'd like to have a "superset schema" that combines all the other schemas, where all fields are nullable.
  • The superset schema can be created using multiple inheritance, but subclassing has to be done in a specific order (since a field may appear in multiple schemas with different nullability settings), or fields must be redefined in the superset schema to allow the nullability of all fields.

The result is the process being inconvenient and leading to code duplication.

Describe the solution you'd like
I'd like Config to have a new attribute, nullable, which would override the nullability setting across all fields.

Describe alternatives you've considered
The LLM proposed to create a mixin, a decorator, a metaclass, etc. However, these approaches rely on doing the equivalent of isinstance(x, pa.Field), which is impossible since it's not a class but a factory method, so chaos ensues.

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions