Coverage for polar/integrations/discord/schemas.py: 64%

12 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 12:42 +0000

1from typing import Any 

2 

3from pydantic import field_validator 

4from pydantic_extra_types.color import Color 

5 

6from polar.kit.schemas import Schema 

7 

8 

9class DiscordGuildRole(Schema): 

10 id: str 

11 name: str 

12 position: int 

13 is_polar_bot: bool 

14 color: Color 

15 

16 @field_validator("color", mode="before") 

17 @classmethod 

18 def int_color_to_hex(cls, v: Any) -> str: 

19 if isinstance(v, int): 

20 return hex(v)[2:].zfill(6) 

21 return v 

22 

23 

24class DiscordGuild(Schema): 

25 name: str 

26 roles: list[DiscordGuildRole]