Skip to content
This repository has been archived by the owner on Sep 14, 2020. It is now read-only.

Resolve special stenzas lazily with no side-effects on the body #198

Merged
merged 4 commits into from
Oct 5, 2019

Conversation

nolar
Copy link
Contributor

@nolar nolar commented Oct 1, 2019

Resolve the special stenzas in the body lazily, on demand, without actual creation.

Issue : #194, #183

Description

There was an issue that spec, status, metadata fields were implicitly added to the body due to body.setdefault(..., {}) usage — even if such a stenzas didn't exist actually. From the users point of view, it appeared unexpectedly — i.e. an undesired side effect.

This was needed to ensure that the spec, status, metadata kwargs are exactly the same in the body kwarg, and any change in either of them is reflected in another one.

With this implementation, a dict-like object is introduced, which resolves these stenzas on-demand. In all other aspects, this object should behave like a normal dict.

In addition, this change is done as a preparation for the throughout type-hinting in the code base. Resolving the cyclic imports becomes important. The whole refactoring is split into few PRs (one per concept) for ease of review.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor/improvements

Tasks

Review

  • Tests
  • Documentation

@zincr
Copy link

zincr bot commented Oct 1, 2019

🤖 zincr found 0 problems , 0 warnings

✅ Large Commits
✅ Approvals
✅ Specification
✅ Dependency Licensing

@nolar nolar marked this pull request as ready for review October 4, 2019 10:36
@nolar nolar requested a review from samurang87 as a code owner October 4, 2019 10:36
jonathanbeber
jonathanbeber previously approved these changes Oct 4, 2019
Copy link

@jonathanbeber jonathanbeber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@nolar nolar force-pushed the typehints-lazydictview branch from 884a8bd to 0eaee56 Compare October 4, 2019 16:18
@nolar nolar requested a review from jonathanbeber October 4, 2019 16:21
@nolar nolar merged commit d6bafae into zalando-incubator:master Oct 5, 2019
@nolar nolar deleted the typehints-lazydictview branch October 5, 2019 08:44
@nolar nolar added the enhancement New feature or request label Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants