File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 4
4
import logging
5
5
6
6
from enum import Enum
7
- from pydantic import BaseModel , Field
7
+ from pydantic import BaseModel , Field , Extra
8
8
9
9
from typing_extensions import Annotated
10
10
from typing import Literal , Union , Optional
16
16
class _Base (BaseModel ):
17
17
"""Any data class that might appear in the quartodoc config."""
18
18
19
+ class Config :
20
+ extra = Extra .forbid
21
+
19
22
20
23
class _Structural (_Base ):
21
24
"""A structural element, like an index Section or Page of docs."""
@@ -245,6 +248,7 @@ class Link(_Docable):
245
248
246
249
class Config :
247
250
arbitrary_types_allowed = True
251
+ extra = Extra .forbid
248
252
249
253
250
254
class Doc (_Docable ):
@@ -275,6 +279,7 @@ class Doc(_Docable):
275
279
276
280
class Config :
277
281
arbitrary_types_allowed = True
282
+ extra = Extra .forbid
278
283
279
284
@classmethod
280
285
def from_griffe (
@@ -374,6 +379,7 @@ class Item(BaseModel):
374
379
375
380
class Config :
376
381
arbitrary_types_allowed = True
382
+ extra = Extra .forbid
377
383
378
384
379
385
# Update forwared refs --------------------------------------------------------
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
+ from pydantic import ValidationError
3
4
from quartodoc .layout import Layout , Page , Text , Section # noqa
4
5
5
6
@@ -27,3 +28,10 @@ def test_layout_from_config(cfg, res):
27
28
28
29
layout = Layout (sections = [cfg ])
29
30
assert layout .sections [0 ] == res
31
+
32
+
33
+ def test_layout_extra_forbidden ():
34
+ with pytest .raises (ValidationError ) as exc_info :
35
+ Section (title = "abc" , desc = "xyz" , contents = [], zzzzz = 1 )
36
+
37
+ assert "extra fields not permitted" in str (exc_info .value )
You can’t perform that action at this time.
0 commit comments