3
3
from datetime import date
4
4
from typing import Any
5
5
6
- from pydantic import BaseModel , EmailStr , Field , HttpUrl , validator
6
+ from pydantic import field_validator , BaseModel , EmailStr , Field , HttpUrl
7
7
8
8
9
9
class ProjectItem (BaseModel ):
10
10
''' ProjectItem '''
11
11
id : str = Field (description = '`pid`, project id' )
12
12
name : str = Field (description = 'project name' )
13
- desc : str | None = Field (description = 'desc' )
14
- action_date : date | None = Field (description = 'action date' )
15
- owners : list [str ] | None = Field (description = 'list of owners' )
16
- calendar : str | None = Field (description = 'calendar url' )
17
- gitlab_project_id : str | None = Field (description = 'gitlab project id' )
13
+ desc : str | None = Field (None , description = 'desc' )
14
+ action_date : date | None = Field (None , description = 'action date' )
15
+ owners : list [str ] | None = Field (None , description = 'list of owners' )
16
+ calendar : str | None = Field (None , description = 'calendar url' )
17
+ gitlab_project_id : str | None = Field (None , description = 'gitlab project id' )
18
18
mailling_leader : EmailStr | None = Field (
19
- description = 'mailing list of leader' )
19
+ None , description = 'mailing list of leader' )
20
20
mailling_staff : EmailStr | None = Field (
21
- description = 'mailing list of staff' )
21
+ None , description = 'mailing list of staff' )
22
22
mattermost_ch_id : str | None = Field (
23
- description = 'Mattermost main channel id' )
24
- shared_drive : HttpUrl | None = Field (description = 'Google shared drive' )
23
+ None , description = 'Mattermost main channel id' )
24
+ shared_drive : HttpUrl | None = Field (None , description = 'Google shared drive' )
25
25
traffic_fee_doc : HttpUrl | None = Field (
26
- description = 'doc fields for traffic fee' )
26
+ None , description = 'doc fields for traffic fee' )
27
27
volunteer_certificate_hours : int | None = Field (
28
- description = 'hours for volunteer certificate' )
28
+ None , description = 'hours for volunteer certificate' )
29
29
30
- @validator ('*' , pre = True )
30
+ @field_validator ('*' , mode = "before" )
31
+ @classmethod
31
32
def skip_empty_str (cls , value : Any ) -> Any : # pylint:disable=no-self-argument
32
33
''' skip empty string '''
33
34
if isinstance (value , str ):
@@ -44,13 +45,14 @@ class TeamItem(BaseModel):
44
45
pid : str = Field (description = '`pid`, project id' )
45
46
id : str = Field (description = '`tid`, team id' )
46
47
name : str = Field (description = 'team name' )
47
- chiefs : list [str ] | None = Field (description = "list of chiefs' uids" )
48
- members : list [str ] | None = Field (description = "list of members' uids" )
49
- desc : str | None = Field (description = 'desc' )
50
- mailling : EmailStr | None = Field (description = 'mailing list for team' )
51
- headcount : int | None = Field (description = 'the headcount of team' )
48
+ chiefs : list [str ] | None = Field (None , description = "list of chiefs' uids" )
49
+ members : list [str ] | None = Field (None , description = "list of members' uids" )
50
+ desc : str | None = Field (None , description = 'desc' )
51
+ mailling : EmailStr | None = Field (None , description = 'mailing list for team' )
52
+ headcount : int | None = Field (None , description = 'the headcount of team' )
52
53
53
- @validator ('*' , pre = True )
54
+ @field_validator ('*' , mode = "before" )
55
+ @classmethod
54
56
def skip_empty_str (cls , value : Any ) -> Any : # pylint:disable=no-self-argument
55
57
''' skip empty string '''
56
58
if isinstance (value , str ):
@@ -72,6 +74,6 @@ class UserItem(BaseModel):
72
74
id : str = Field (description = 'user id' )
73
75
badge_name : str = Field (description = 'badge name' )
74
76
avatar : HttpUrl = Field (description = 'url for avatar' )
75
- intro : str | None = Field (description = 'introduction' )
76
- chat : MattermostAccount | None = Field (description = 'Mattermost account' )
77
- is_chief : bool | None = Field (description = 'is the chief in the team' )
77
+ intro : str | None = Field (None , description = 'introduction' )
78
+ chat : MattermostAccount | None = Field (None , description = 'Mattermost account' )
79
+ is_chief : bool | None = Field (None , description = 'is the chief in the team' )
0 commit comments