PyCharm warning: Expected type 'ObjectType', got 'Type[Query]' instead
See original GitHub issue
class Query(graphene.ObjectType):
# ...
schema = Schema(query=Query)
Related to #814 which was automatically closed due to staleness.
Any ideas?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:15
- Comments:16 (1 by maintainers)
Top Results From Across the Web
How to deal with PyCharm's "Expected type X, got Y instead"
Expand the Python tab. Scroll down to Type Checker and uncheck it. PyCharm should now stop issuing warnings about incorrect function arguments.
Read more >Expected type 'ObjectType', got 'Type[Query]' instead
PyCharm warning : Expected type 'ObjectType', got 'Type[Query]' instead.
Read more >False Positive: Expected type 'type', got 'object' instead for ...
Run PyCharm and create a new python project with python 3.8 ... PyCharm reports warning Expected type 'type', got 'object' instead for TypeVar...
Read more >Expected type 'object', got 'str' instead - JetBrains YouTrack
After the latest upgrade, I have started to get a lot of warnings saying Expected type 'object', got 'str' instead. I don't know...
Read more >Possible type checking bug: Expected type 'Model', got 'Type ...
... type 'Model', got 'Type[Model]' instead. The following code produces wrong type warnings (also happens with other classes). PyCharm installed via snap.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Came across this looking for the same PyCharm warning, but in a different situation. I’m not a user of this repo, so I won’t take the time to locate the code and PR the simple fix for it.
TL/DR:
Whenever you see PyCharm complain with
that’s a possible type hinting misunderstanding. See this for more information.
In summary:
change the doc present in graphene/types/schema.py
replace:
query (ObjectType): Root query ObjectType. Describes entry point for fields to read data in your Schema.
with
query (Type[ObjectType]): Root query ObjectType. Describes entry point for fields to read data in your Schema.
After that problem will resolve