Repository navigation
Conversation
helderco
marked this pull request as draft
November 23, 2023 23:53
Contributor
Author
|
I'm going to make some changes:
|
Signed-off-by: Helder Correia <[email protected]>
Most importantly, greatly increased test coverage which squashed a few bugs, and additionally added support for async constructor and to create functions from another object's constructor. Signed-off-by: Helder Correia <[email protected]>
helderco
force-pushed
the
helder/dev-3059-support-for-constructors-in-python-modules
branch
from
November 28, 2023 15:05
11dbe3f to
7893535
Compare
helderco
marked this pull request as ready for review
November 28, 2023 15:06
Signed-off-by: Helder Correia <[email protected]>
Contributor
Author
|
Ready for review. |
Contributor
|
Waiting on this one to get merged so that the following security items will get fixed: |
sipsma
approved these changes
Nov 28, 2023
helderco
deleted the
helder/dev-3059-support-for-constructors-in-python-modules
branch
November 28, 2023 22:52
Merged
This was referenced Dec 6, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #6135
Equivalent example in Python:
Async support
To support async operations in a constructor, an alternative factory classmethod named "create" can be used for greater control over the initialization:
This makes the
srcargument optional in the constructor, but not optional when instantiating. The following command will callTest.create(), which in turn instantiatesTest(src)with an async default value.Note that this factory also works non-async.
DX sugar on chaining
This change also adds DX sugar for reducing boilerplate when chaining into other objects, by making a function that’s based on another object’s constructor.
For example, with the following objects:
Before
After
It’s more noticeable the more arguments, default values and documentation there is.