File tree Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Expand file tree Collapse file tree 2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -71,22 +71,26 @@ def load_vocabulary(name):
71
71
return vocabulary
72
72
73
73
74
- def format_as_index (indices ):
74
+ def format_as_index (container , indices ):
75
75
"""
76
76
Construct a single string containing indexing operations for the indices.
77
77
78
- For example, [1, 2, "foo"] -> [1][2]["foo"]
78
+ For example for a container ``bar`` , [1, 2, "foo"] -> bar [1][2]["foo"]
79
79
80
80
Arguments:
81
81
82
+ container (str):
83
+
84
+ A word to use for the thing being indexed
85
+
82
86
indices (sequence):
83
87
84
88
The indices to format.
85
89
"""
86
90
87
91
if not indices :
88
- return ""
89
- return f"[{ '][' .join (repr (index ) for index in indices )} ]"
92
+ return container
93
+ return f"{ container } [{ '][' .join (repr (index ) for index in indices )} ]"
90
94
91
95
92
96
def find_additional_properties (instance , schema ):
Original file line number Diff line number Diff line change @@ -66,22 +66,24 @@ def __str__(self):
66
66
if any (m is _unset for m in essential_for_verbose ):
67
67
return self .message
68
68
69
- schema_word = self ._word_for_schema_in_error_message
70
69
schema_path = _utils .format_as_index (
71
- list (self .relative_schema_path )[:- 1 ],
70
+ container = self ._word_for_schema_in_error_message ,
71
+ indices = list (self .relative_schema_path )[:- 1 ],
72
+ )
73
+ instance_path = _utils .format_as_index (
74
+ container = self ._word_for_instance_in_error_message ,
75
+ indices = self .relative_path ,
72
76
)
73
- instance_word = self ._word_for_instance_in_error_message
74
- instance_path = _utils .format_as_index (self .relative_path )
75
77
prefix = 16 * " "
76
78
77
79
return dedent (
78
80
f"""\
79
81
{ self .message }
80
82
81
- Failed validating { self .validator !r} in { schema_word } { schema_path } :
83
+ Failed validating { self .validator !r} in { schema_path } :
82
84
{ indent (pformat (self .schema , width = 72 ), prefix ).lstrip ()}
83
85
84
- On { instance_word } { instance_path } :
86
+ On { instance_path } :
85
87
{ indent (pformat (self .instance , width = 72 ), prefix ).lstrip ()}
86
88
""" .rstrip (),
87
89
)
You can’t perform that action at this time.
0 commit comments