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

AssertionError: Found different types with the same name in the schema: Foo, Foo. #34

Closed
dantp-ai opened this issue Jul 30, 2020 · 6 comments

Comments

@dantp-ai
Copy link

dantp-ai commented Jul 30, 2020

@necaris I get AssertionError: Found different types with the same name in the schema: Foo, Foo. if I run test_query from test_forward_refs.py twice!

@necaris
Copy link
Collaborator

necaris commented Aug 2, 2020

@plopd Can you give us some more detail on how you're running it -- can you paste some code from your application where this is coming up?

@dantp-ai
Copy link
Author

dantp-ai commented Aug 3, 2020

Given the same python environment I ran the code inside the test_forward_refs.py twice in succession.

@dantp-ai
Copy link
Author

dantp-ai commented Aug 3, 2020

Your tests don't pass fully with pytest, given Python 3.6.0, where all the dependencies were installed with poetry!!

~/r/g/graphene-pydantic ❯❯❯ poetry run pytest                                                                               ✘ 130
======================================================= test session starts =======================================================
platform darwin -- Python 3.6.0, pytest-4.6.11, py-1.9.0, pluggy-0.13.1
rootdir: /../graphene_pydantic/graphene-pydantic
plugins: cov-2.7.1
collected 33 items / 1 errors / 32 selected

============================================================= ERRORS ==============================================================
___________________________________________ ERROR collecting tests/test_forward_refs.py ___________________________________________
tests/test_forward_refs.py:33: in <module>
    class Foo(PydanticObjectType):
.venv/lib/python3.6/site-packages/graphene/utils/subclass_with_meta.py:52: in __init_subclass__
    super_class.__init_subclass_with_meta__(**options)
graphene_pydantic/objecttype.py:95: in __init_subclass_with_meta__
    exclude_fields=exclude_fields,
graphene_pydantic/objecttype.py:47: in construct_fields
    field, registry, parent_type=obj_type, model=model
graphene_pydantic/converters.py:130: in convert_pydantic_field
    declared_type, field, registry, parent_type=parent_type, model=model
graphene_pydantic/converters.py:157: in convert_pydantic_type
    type_, field, registry, parent_type=parent_type, model=model
graphene_pydantic/converters.py:213: in find_graphene_type
    elif isinstance(type_, T.ForwardRef):
E   AttributeError: module 'typing' has no attribute 'ForwardRef'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================== 1 error in 4.43 seconds =====================================================

@necaris
Copy link
Collaborator

necaris commented Aug 3, 2020

@plopd Thank you for finding this! We will have to add a better error message -- unfortunately the forward refs feature requires Python 3.7+ as in upstream Pydantic -- https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ . So that test is not expected to pass on Python 3.6.

@dantheman39
Copy link
Contributor

@plopd Yes, ForwardRef isn't available in python 3.6, thanks for catching that. Note that there are other caveats with python 3.6 (Union Types not working specifically, due to 3.6's implementation of them).

So of course this code and the messaging can use some improvements, but in the meantime if you're able to use python 3.7 you'll have better results. Thanks again for finding the issue.

@necaris
Copy link
Collaborator

necaris commented Nov 22, 2020

Closing this as it's been >3 months with no further action needed 😄

@necaris necaris closed this as completed Nov 22, 2020
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

3 participants