From b274a607f403b3e5758f4cd4fd9508116018e9a2 Mon Sep 17 00:00:00 2001 From: belkka Date: Mon, 11 Oct 2021 23:46:13 +0300 Subject: [PATCH] Avoid ambiguity in graphene.Mutation docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code example in docstring starts with `from graphene import Mutation` and defines a `class Mutation` later. This definition would shadow previously imported name and (which is more important) confuses a reader about usage of this class — one need to keep in mind that previous usage of `Mutation` is imported from graphene and have not been overridden yet. This PR changes an import-from statement to an import statement, so `graphene.Mutation` is used explicitly. This approach is consistent with other code examples in docs (e. g. https://docs.graphene-python.org/en/v2.1.9/types/mutations/). Another option is to change name of example class Mutation to something more clear (maybe SchemaMutation or RootMutation), but I'm not sure what name to choose. Only docstring is updated, no code changes. --- graphene/types/mutation.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/graphene/types/mutation.py b/graphene/types/mutation.py index ca87775a..0c55a8b6 100644 --- a/graphene/types/mutation.py +++ b/graphene/types/mutation.py @@ -29,21 +29,21 @@ class Mutation(ObjectType): .. code:: python - from graphene import Mutation, ObjectType, String, Boolean, Field + import graphene - class CreatePerson(Mutation): + class CreatePerson(graphene.Mutation): class Arguments: - name = String() + name = graphene.String() - ok = Boolean() - person = Field(Person) + ok = graphene.Boolean() + person = graphene.Field(Person) def mutate(parent, info, name): person = Person(name=name) ok = True return CreatePerson(person=person, ok=ok) - class Mutation(ObjectType): + class Mutation(graphene.ObjectType): create_person = CreatePerson.Field() Meta class options (optional):