18
18
used by Bert-E) are declared.
19
19
20
20
"""
21
- from marshmallow import Schema , fields
21
+ from marshmallow import Schema , fields , EXCLUDE
22
22
23
23
24
- class User (Schema ):
24
+ class GitHubSchema (Schema ):
25
+ class Meta :
26
+ unknown = EXCLUDE
27
+
28
+
29
+ class User (GitHubSchema ):
25
30
id = fields .Int (required = True )
26
31
login = fields .Str (required = True )
27
32
# Note: the "printable" name can be absent in most API call results.
@@ -30,7 +35,7 @@ class User(Schema):
30
35
type = fields .Str ()
31
36
32
37
33
- class Repo (Schema ):
38
+ class Repo (GitHubSchema ):
34
39
name = fields .Str (required = True )
35
40
owner = fields .Nested (User , required = True )
36
41
full_name = fields .Str (required = True )
@@ -41,7 +46,7 @@ class Repo(Schema):
41
46
default_branch = fields .Str ()
42
47
43
48
44
- class CreateRepo (Schema ):
49
+ class CreateRepo (GitHubSchema ):
45
50
name = fields .Str (required = True )
46
51
description = fields .Str ()
47
52
homepage = fields .Url ()
@@ -54,14 +59,14 @@ class CreateRepo(Schema):
54
59
licence_template = fields .Str ()
55
60
56
61
57
- class Status (Schema ):
62
+ class Status (GitHubSchema ):
58
63
state = fields .Str (required = True )
59
64
target_url = fields .Str (required = True , allow_none = True )
60
65
description = fields .Str (required = True , allow_none = True )
61
66
context = fields .Str (required = True )
62
67
63
68
64
- class AggregatedStatus (Schema ):
69
+ class AggregatedStatus (GitHubSchema ):
65
70
# The most convenient way to get a pull request's build status is to
66
71
# query github's API for an aggregated status.
67
72
state = fields .Str ()
@@ -70,23 +75,23 @@ class AggregatedStatus(Schema):
70
75
statuses = fields .Nested (Status , many = True , required = True )
71
76
72
77
73
- class Branch (Schema ):
78
+ class Branch (GitHubSchema ):
74
79
label = fields .Str () # user:ref or org:ref
75
80
ref = fields .Str ()
76
81
sha = fields .Str ()
77
82
user = fields .Nested (User )
78
83
repo = fields .Nested (Repo )
79
84
80
85
81
- class App (Schema ):
86
+ class App (GitHubSchema ):
82
87
id = fields .Int ()
83
88
slug = fields .Str ()
84
89
owner = fields .Nested (User )
85
90
name = fields .Str ()
86
91
description = fields .Str ()
87
92
88
93
89
- class CheckSuite (Schema ):
94
+ class CheckSuite (GitHubSchema ):
90
95
id = fields .Integer ()
91
96
head_sha = fields .Str ()
92
97
head_branch = fields .Str ()
@@ -98,20 +103,20 @@ class CheckSuite(Schema):
98
103
app = fields .Nested (App )
99
104
100
105
101
- class AggregateCheckSuites (Schema ):
106
+ class AggregateCheckSuites (GitHubSchema ):
102
107
total_count = fields .Integer ()
103
108
check_suites = fields .Nested (CheckSuite , many = True )
104
109
105
110
106
- class CheckRun (Schema ):
111
+ class CheckRun (GitHubSchema ):
107
112
id = fields .Integer ()
108
113
head_sha = fields .Str ()
109
114
status = fields .Str ()
110
115
conclusion = fields .Str (allow_none = True )
111
116
html_url = fields .Url ()
112
117
113
118
114
- class WorkflowRun (Schema ):
119
+ class WorkflowRun (GitHubSchema ):
115
120
id = fields .Integer ()
116
121
head_sha = fields .Str ()
117
122
head_branch = fields .Str ()
@@ -121,17 +126,17 @@ class WorkflowRun(Schema):
121
126
event = fields .Str ()
122
127
123
128
124
- class AggregateWorkflowRuns (Schema ):
129
+ class AggregateWorkflowRuns (GitHubSchema ):
125
130
total_count = fields .Integer ()
126
131
workflow_runs = fields .Nested (WorkflowRun , many = True )
127
132
128
133
129
- class AggregateCheckRuns (Schema ):
134
+ class AggregateCheckRuns (GitHubSchema ):
130
135
total_count = fields .Integer ()
131
136
check_runs = fields .Nested (CheckRun , many = True )
132
137
133
138
134
- class PullRequest (Schema ):
139
+ class PullRequest (GitHubSchema ):
135
140
number = fields .Int (required = True )
136
141
url = fields .Url ()
137
142
html_url = fields .Url ()
@@ -149,23 +154,23 @@ class PullRequest(Schema):
149
154
merged_at = fields .DateTime (allow_none = True )
150
155
151
156
152
- class CreatePullRequest (Schema ):
157
+ class CreatePullRequest (GitHubSchema ):
153
158
title = fields .Str (required = True )
154
159
head = fields .Str (required = True )
155
160
base = fields .Str (required = True )
156
161
body = fields .Str ()
157
162
maintainer_can_modify = fields .Bool ()
158
163
159
164
160
- class UpdatePullRequest (Schema ):
165
+ class UpdatePullRequest (GitHubSchema ):
161
166
title = fields .Str ()
162
167
body = fields .Str ()
163
168
state = fields .Str ()
164
169
base = fields .Str ()
165
170
maintainer_can_modify = fields .Bool ()
166
171
167
172
168
- class Comment (Schema ):
173
+ class Comment (GitHubSchema ):
169
174
id = fields .Int (required = True )
170
175
body = fields .Str ()
171
176
created_at = fields .DateTime ()
@@ -174,61 +179,61 @@ class Comment(Schema):
174
179
url = fields .Url ()
175
180
176
181
177
- class CreateComment (Schema ):
182
+ class CreateComment (GitHubSchema ):
178
183
body = fields .Str (required = True )
179
184
180
185
181
- class Review (Schema ):
186
+ class Review (GitHubSchema ):
182
187
id = fields .Int (allow_none = True )
183
188
body = fields .Str (allow_none = True )
184
189
commit_id = fields .Str ()
185
190
state = fields .Str ()
186
191
user = fields .Nested (User )
187
192
188
193
189
- class DraftReview (Schema ):
194
+ class DraftReview (GitHubSchema ):
190
195
path = fields .Str ()
191
196
position = fields .Int ()
192
197
body = fields .Str ()
193
198
194
199
195
- class CreateReview (Schema ):
200
+ class CreateReview (GitHubSchema ):
196
201
body = fields .Str (allow_none = True )
197
202
event = fields .Str ()
198
203
199
204
200
- class PullRequestEvent (Schema ):
205
+ class PullRequestEvent (GitHubSchema ):
201
206
action = fields .Str (required = True )
202
207
number = fields .Int ()
203
208
pull_request = fields .Nested (PullRequest )
204
209
205
210
206
- class Issue (Schema ):
211
+ class Issue (GitHubSchema ):
207
212
number = fields .Int ()
208
213
title = fields .Str ()
209
214
# If this dict is present and non-empty, then the issue is a pull request.
210
215
pull_request = fields .Dict (optional = True , default = {})
211
216
212
217
213
- class IssueCommentEvent (Schema ):
218
+ class IssueCommentEvent (GitHubSchema ):
214
219
action = fields .Str ()
215
220
issue = fields .Nested (Issue )
216
221
217
222
218
- class PullRequestReviewEvent (Schema ):
223
+ class PullRequestReviewEvent (GitHubSchema ):
219
224
action = fields .Str ()
220
225
pull_request = fields .Nested (PullRequest )
221
226
222
227
223
- class StatusEvent (Schema ):
228
+ class StatusEvent (GitHubSchema ):
224
229
sha = fields .Str ()
225
230
state = fields .Str ()
226
231
context = fields .Str ()
227
232
description = fields .Str (allow_none = True )
228
233
target_url = fields .Str (allow_none = True )
229
234
230
235
231
- class CheckSuiteEvent (Schema ):
236
+ class CheckSuiteEvent (GitHubSchema ):
232
237
action = fields .Str ()
233
238
check_suite = fields .Nested (CheckSuite )
234
239
repository = fields .Nested (Repo )
0 commit comments