Skip to content

Commit 42b14fa

Browse files
fix: from_descriptor not possible
`from_descriptor` leads to a `RecursionError`
1 parent a7a01b4 commit 42b14fa

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

frictionless/schema/field.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import decimal
44
import re
55
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)
78

89
import attrs
910

@@ -50,7 +51,9 @@ class Field(Metadata):
5051
For example: "default","array" etc.
5152
"""
5253

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+
)
5457
"""
5558
List of string values to be set as missing values in the field. If any of string in missing values
5659
is found in the field value then it is set as None.
@@ -260,10 +263,12 @@ def metadata_validate(cls, descriptor: IDescriptor): # type: ignore
260263
if example:
261264
type = descriptor.get("type")
262265
Class = system.select_field_class(type)
266+
263267
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"),
266270
)
271+
267272
if type == "boolean":
268273
# 'example' value must be compared to customized 'trueValues' and 'falseValues'
269274
if "trueValues" in descriptor.keys():
@@ -272,7 +277,9 @@ def metadata_validate(cls, descriptor: IDescriptor): # type: ignore
272277
field.false_values = descriptor["falseValues"]
273278
_, notes = field.read_cell(example)
274279
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+
)
276283
yield errors.FieldError(note=note)
277284

278285
# Misleading

0 commit comments

Comments
 (0)