graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

Fix type hint for DjangoObjectTypeOptions.model

Open belkka opened this issue 4 years ago • 1 comments

Proper type is typing.Type[Model], not Model

belkka avatar Nov 09 '21 18:11 belkka

Also, according to usage, https://github.com/graphql-python/graphene-django/blob/9f26772ae02106d723ca27b88eb10660c05df8d8/graphene_django/types.py#L192

there could be added type hints for fields and exclude:

class DjangoObjectTypeOptions(ObjectTypeOptions):
    ...
    fields = None  # type: Union[List[str], Tuple[str, ...], Literal['__all__']]
    exclude = None  # type: Union[List[str], Tuple[str, ...]]

This would fix mismatching type hint inherited from ObjectTypeOptions.fields, which is annotated as following in graphene: fields = None # type: Dict[str, Field]

typing.Literal is new in python3.8, so could use str instead of Literal['__all__']

belkka avatar Nov 09 '21 18:11 belkka