Stranger6667 / hypothesis-graphql

Generate arbitrary queries matching your GraphQL schema, and use them to verify your backend implementation.
https://pypi.org/project/hypothesis-graphql/
MIT License
44 stars 2 forks source link

Unable to import from_schema from hypothesis_graphql #105

Closed Sukeerthi31 closed 7 months ago

Sukeerthi31 commented 7 months ago

Describe the bug Unable to import from_schema from hypothesis_graphql

To Reproduce Steps to reproduce the behaviour:

  1. My GraphQL schema is - the sample schema provided in the README
  2. Run this command - python3 hypothesis_graphql.py
  3. See error - ImportError: cannot import name 'from_schema' from partially initialized module 'hypothesis_graphql' (most likely due to a circular import) (file-path/hypothesis_graphql.py)

Expected behavior Imports to go through correctly

Environment (please complete the following information):

Stranger6667 commented 7 months ago

This issue is not relevant to hypothesis_graphql. The same could be achieved with sample.py:

from sample import foo

def foo():
    print("Hello from foo!")
> python sample.py
Traceback (most recent call last):
  File "/tmp/sample.py", line 1, in <module>
    from sample import foo
  File "/tmp/sample.py", line 1, in <module>
    from sample import foo
ImportError: cannot import name 'foo' from partially initialized module 'sample' (most likely due to a circular import) (/tmp/sample.py)
Stranger6667 commented 7 months ago

I.e. you should not name your sample file the same as the module you have imports from.