question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to support namedtuple in event state?

See original GitHub issue

One of my events has a namedtuple in its state. This event mutate the state of its parent entity as follow:

    class SomethingAdded(BaseAggregateRoot.Event):
        def mutate(self, obj):
            obj.things = (*obj.things, self.my_namedtuple)   

But when restoring the entity from the repository, the things attribute has the following structure:

([...], [...])

clearly the namedtuple are replaced with list, so how to retrieve the entity while preserve it original state?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16

github_iconTop GitHub Comments

1reaction
johnbywatercommented, Oct 14, 2019

Thanks for offering to help, @adnanmuttaleb. Perhaps if you haven’t already, you could join the Slack channel and we can chat about it there? If you don’t like Slack, we can continue to discuss things here, or elsewhere e.g. by email (mine is in the setup.py file).

0reactions
johnbywatercommented, Dec 26, 2019

Does this help? 6c79fa1259f8b0cba74ca5088275fa71036a3ef5

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to support namedtuple in event state? · Issue #191 ... - GitHub
One of my events has a namedtuple in its state. This event mutate the state of its parent entity as follow: class SomethingAdded(BaseAggregateRoot....
Read more >
Write Pythonic and Clean Code With namedtuple - Real Python
With NamedTuple , you can create tuple subclasses that support type hints and attribute access through the dot notation. Since the resulting class...
Read more >
What is the fastest (to access) struct-like object in Python?
One thing to bear in mind is that namedtuples are optimised for access as tuples. If you change your accessor to be a[2]...
Read more >
Tuple types - C# reference - Microsoft Learn
Tuple types support equality operators == and != . For more information, see the Tuple equality section. Tuple types are value types; ...
Read more >
++namedtuple - Python-style Named Tuples in C++20
01 const auto tuple = namedtuple {"price"_t = 42, ... where he uses template meta-programming techniques to support the C++ rule - "Don't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found