Skip to content

Conversation

@UnravelSports
Copy link
Contributor

I know it's not ideal to introduce breaking changes, but having home_coach and away_coach live directly in the Metadata is not ideal either. I've removed them from Metadata and added coach under Team such that we get:

@dataclass
class Team:
    """
    A team in a match.

    Attributes:
        team_id (str): Identifier given by the provider.
        name (str): Readable name of the team.
        ground (Ground): The team's ground (home or away).
        players (List[Player]): The team's players.
        starting_formation (FormationType, optional): The team's starting formation.
        coach (str, optional): The team's coach.
    """

    team_id: str
    name: str
    ground: Ground
    starting_formation: FormationType | None = None
    formations: TimeContainer[FormationType] = field(
        default_factory=TimeContainer, compare=False
    )
    players: list[Player] = field(default_factory=list)
    coach: str | None = None
    ...

I've updated the code for all providers that currently have coaches set within the deserializer, and updated the tests accordingly too.

@probberechts
Copy link
Contributor

probberechts commented Dec 17, 2025

I agree!

Can we use a deprecated property to avoid introducing a breaking change?

from kloppy.utils import deprecated

class Metadata
    ...

    @property
    @deprecated("Use teams[0].coach instead")
    def home_coach(self) -> str | None:
        return self.teams[0].coach if self.teams else None

    @property
    @deprecated("Use teams[1].coach instead")
    def away_coach(self) -> str | None:
        return self.teams[1].coach if self.teams else None

@UnravelSports
Copy link
Contributor Author

Good point, forgot about that. I've added it in!

@probberechts probberechts linked an issue Dec 22, 2025 that may be closed by this pull request
@probberechts probberechts merged commit ddfbbdc into PySport:master Dec 23, 2025
20 checks passed
@probberechts probberechts added this to the 3.19.0 milestone Jan 8, 2026
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.

[METADATA] Why is home_coach and away_coach in Metadata?

2 participants