File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class _DocModifier(_schema.PropertyModifier):
16
16
doc : str
17
17
18
18
def modify (self , prop : _schema .Property ):
19
+ if "\n " in self .doc or self .doc [- 1 ] == "." :
20
+ raise _schema .Error ("No newlines or trailing dots are allowed in doc, did you intend to use desc?" )
19
21
prop .doc = self .doc
20
22
21
23
Original file line number Diff line number Diff line change @@ -559,6 +559,22 @@ class A:
559
559
}
560
560
561
561
562
+ def test_property_doc_override_no_newlines ():
563
+ with pytest .raises (schema .Error ):
564
+ @schema .load
565
+ class data :
566
+ class A :
567
+ x : int | defs .doc ("no multiple\n lines" )
568
+
569
+
570
+ def test_property_doc_override_no_trailing_dot ():
571
+ with pytest .raises (schema .Error ):
572
+ @schema .load
573
+ class data :
574
+ class A :
575
+ x : int | defs .doc ("no dots please." )
576
+
577
+
562
578
def test_class_default_doc_name ():
563
579
@schema .load
564
580
class data :
You can’t perform that action at this time.
0 commit comments