Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer cannot deserialize Alternatives of the same name and signature in different modules #436

Open
wllgrnt opened this issue Feb 14, 2023 · 0 comments

Comments

@wllgrnt
Copy link

wllgrnt commented Feb 14, 2023

Given three files:

#module_1.py

from typed_python import Alternative, SerializationContext, Entrypoint

def clone(x):
    return SerializationContext().deserialize(SerializationContext().serialize(x))

@Entrypoint
def test_alternative_hashing():
    A = Alternative("A", A=dict(a=int))
    print('A from module 1', A, 'clones to', clone(A))
    return A

test_alternative_hashing()
#module_2.py

from typed_python import Alternative, SerializationContext, Entrypoint
from alternative_serialisation_module import clone

@Entrypoint
def test_alternative_hashing_2():
    A = Alternative("A", A=dict(a=int))
    print('A from module 2', A, 'clones to', clone(A))
    return A

test_alternative_hashing_2()
#module_3.py

from module_1 import test_alternative_hashing
from module_2 import test_alternative_hashing_2

Run module_3.py.

Expected output

A from module 1 <class 'module_1.A'> clones to <class 'module_1.A'>
A from module 2 <class 'module_2.A'> clones to <class 'module_2.A'>

Actual output

A from module 1 <class 'module_1.A'> clones to <class 'module_1.A'>
A from module 2 <class 'module_2.A'> clones to <class 'module_1.A'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant