3
3
import decimal
4
4
import re
5
5
from functools import partial
6
- from typing import TYPE_CHECKING , Any , Callable , ClassVar , Dict , List , Optional , Pattern
6
+ from typing import (TYPE_CHECKING , Any , Callable , ClassVar , Dict , List ,
7
+ Optional , Pattern )
7
8
8
9
import attrs
9
10
@@ -50,7 +51,9 @@ class Field(Metadata):
50
51
For example: "default","array" etc.
51
52
"""
52
53
53
- missing_values : List [str ] = attrs .field (factory = settings .DEFAULT_MISSING_VALUES .copy )
54
+ missing_values : List [str ] = attrs .field (
55
+ factory = settings .DEFAULT_MISSING_VALUES .copy
56
+ )
54
57
"""
55
58
List of string values to be set as missing values in the field. If any of string in missing values
56
59
is found in the field value then it is set as None.
@@ -260,10 +263,12 @@ def metadata_validate(cls, descriptor: IDescriptor): # type: ignore
260
263
if example :
261
264
type = descriptor .get ("type" )
262
265
Class = system .select_field_class (type )
266
+
263
267
field = Class (
264
- name = descriptor .get ("name" , "example" ),
265
- format = descriptor .get ("format" , "default" ), # type: ignore
268
+ name = descriptor .get ("name" ), # type: ignore
269
+ format = descriptor .get ("format" , "default" ),
266
270
)
271
+
267
272
if type == "boolean" :
268
273
# 'example' value must be compared to customized 'trueValues' and 'falseValues'
269
274
if "trueValues" in descriptor .keys ():
@@ -272,7 +277,9 @@ def metadata_validate(cls, descriptor: IDescriptor): # type: ignore
272
277
field .false_values = descriptor ["falseValues" ]
273
278
_ , notes = field .read_cell (example )
274
279
if notes is not None :
275
- note = f'example value "{ example } " for field "{ field .name } " is not valid'
280
+ note = (
281
+ f'example value "{ example } " for field "{ field .name } " is not valid'
282
+ )
276
283
yield errors .FieldError (note = note )
277
284
278
285
# Misleading
0 commit comments