Skip to content

Commit 414d0ab

Browse files
authored
Merge pull request #265 from m-aciek/shorten-tracebacks
2 parents 9fa6a84 + 72b3d0a commit 414d0ab

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

.pylintrc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ disable=print-statement,
150150
import-outside-toplevel,
151151
isinstance-second-argument-not-valid-type,
152152
unsubscriptable-object,
153-
comparison-with-callable,
154-
raise-missing-from
153+
comparison-with-callable
155154

156155
# Enable the message, report, category or checker with the given id(s). You can
157156
# either give multiple identifier separated by comma (,) or put this option

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616
### Fixed
1717

1818
- Fix value creation for a field with a default factory
19+
- Suppress context in dacite ForwardReferenceError and MissingValueError
1920

2021
## [1.8.0] - 2023-01-26
2122

dacite/core.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ def from_dict(data_class: Type[T], data: Data, config: Optional[Config] = None)
5252
try:
5353
data_class_hints = cache(get_concrete_type_hints)(data_class, localns=config.hashable_forward_references)
5454
except NameError as error:
55-
raise ForwardReferenceError(str(error))
56-
55+
raise ForwardReferenceError(str(error)) from None
5756
data_class_fields = cache(get_fields)(data_class)
5857

5958
if config.strict:
@@ -79,8 +78,7 @@ def from_dict(data_class: Type[T], data: Data, config: Optional[Config] = None)
7978
except DefaultValueNotFoundError:
8079
if not field.init:
8180
continue
82-
raise MissingValueError(field.name)
83-
81+
raise MissingValueError(field.name) from None
8482
if field.init:
8583
init_values[field.name] = value
8684
elif not is_frozen(data_class):

tests/core/test_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class X:
6969

7070
assert str(exception_info.value) == 'missing value for field "i"'
7171
assert exception_info.value.field_path == "i"
72+
assert exception_info._excinfo[1].__suppress_context__
7273

7374

7475
def test_from_dict_with_nested_data_class():

tests/core/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class Y:
147147
from_dict(X, {"y": {"s": "text"}})
148148

149149
assert str(exception_info.value) == "can not resolve forward reference: name 'Y' is not defined"
150+
assert exception_info._excinfo[1].__suppress_context__
150151

151152

152153
def test_form_dict_with_disabled_type_checking():

0 commit comments

Comments
 (0)