Skip to content

PassEvent fields should be optional but are declared as required #512

@DriesDeprest

Description

@DriesDeprest

Problem

The PassEvent class declares three fields as required, but many serializers set them to None because data providers don't always provide this information:

@dataclass(repr=False)
class PassEvent(Event):
    receive_timestamp: float              # Declared as required
    receiver_player: Player               # Declared as required
    receiver_coordinates: Point           # Declared as required
    result: PassResult

Evidence

  • receiver_player: Set to None in 13+ serializers (impect, metrica, sportec, scisports, statsbomb, smrtstats, datafactory, korastats, statsperform, wyscout v3)
  • receiver_coordinates: Set to None in 6+ serializers (impect, wyscout v2/v3, metrica, sportec, datafactory)
  • receive_timestamp: Set to None in 5+ serializers (smrtstats, metrica, statsperform, sportec)

Impact

  • Type hints are violated (mypy/pyright would flag errors)
  • Misleading API - suggests fields are always available
  • Potential runtime errors when code assumes non-None values

Proposed Solution

Make these fields explicitly optional, matching the pattern used in ShotEvent.result_coordinates:

@dataclass(repr=False)
class PassEvent(Event):
    receive_timestamp: Optional[float] = None
    receiver_player: Optional[Player] = None
    receiver_coordinates: Optional[Point] = None
    result: PassResult

This is backwards compatible at runtime but properly reflects the actual data model.

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