Skip to content

Commit

Permalink
Merge pull request #265 from m-aciek/shorten-tracebacks
Browse files Browse the repository at this point in the history
  • Loading branch information
mciszczon authored Jan 28, 2025
2 parents 9fa6a84 + 72b3d0a commit 414d0ab
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ disable=print-statement,
import-outside-toplevel,
isinstance-second-argument-not-valid-type,
unsubscriptable-object,
comparison-with-callable,
raise-missing-from
comparison-with-callable

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

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

## [1.8.0] - 2023-01-26

Expand Down
6 changes: 2 additions & 4 deletions dacite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def from_dict(data_class: Type[T], data: Data, config: Optional[Config] = None)
try:
data_class_hints = cache(get_concrete_type_hints)(data_class, localns=config.hashable_forward_references)
except NameError as error:
raise ForwardReferenceError(str(error))

raise ForwardReferenceError(str(error)) from None
data_class_fields = cache(get_fields)(data_class)

if config.strict:
Expand All @@ -79,8 +78,7 @@ def from_dict(data_class: Type[T], data: Data, config: Optional[Config] = None)
except DefaultValueNotFoundError:
if not field.init:
continue
raise MissingValueError(field.name)

raise MissingValueError(field.name) from None
if field.init:
init_values[field.name] = value
elif not is_frozen(data_class):
Expand Down
1 change: 1 addition & 0 deletions tests/core/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class X:

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


def test_from_dict_with_nested_data_class():
Expand Down
1 change: 1 addition & 0 deletions tests/core/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ class Y:
from_dict(X, {"y": {"s": "text"}})

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


def test_form_dict_with_disabled_type_checking():
Expand Down

0 comments on commit 414d0ab

Please sign in to comment.