prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Raise ValueError when `field` or `source` decorator was called incorrectly
  Currently there's no error when the developer forgets to follow the `field` or `source` decorator with `("name")`, tricking them into thinking that decorated function has been registered while in fact it wasn't.
  
  We could update implementation for those functions to raise ValueError when `name` attr is not `str`.
  
  </issue>
  <code>
  [start of ariadne/objects.py]
  1 from typing import Callable, Dict, Optional, cast
  2 
  3 from graphql.type import GraphQLNamedType, GraphQLObjectType, GraphQLSchema
  4 
  5 from .resolvers import resolve_to
  6 from .types import Resolver, SchemaBindable
  7 
  8 
  9 class ObjectType(SchemaBindable):
  10     _resolvers: Dict[str, Resolver]
  11 
  12     def __init__(self, name: str) -> None:
  13         self.name = name
  14         self._resolvers = {}
  15 
  16     def field(self, name: str) -> Callable[[Resolver], Resolver]:
  17         return self.create_register_resolver(name)
  18 
  19     def create_register_resolver(self, name: str) -> Callable[[Resolver], Resolver]:
  20         def register_resolver(f: Resolver) -> Resolver:
  21             self._resolvers[name] = f
  22             return f
  23 
  24         return register_resolver
  25 
  26     def set_field(self, name, resolver: Resolver) -> Resolver:
  27         self._resolvers[name] = resolver
  28         return resolver
  29 
  30     def set_alias(self, name: str, to: str) -> None:
  31         self._resolvers[name] = resolve_to(to)
  32 
  33     def bind_to_schema(self, schema: GraphQLSchema) -> None:
  34         graphql_type = schema.type_map.get(self.name)
  35         self.validate_graphql_type(graphql_type)
  36         graphql_type = cast(GraphQLObjectType, graphql_type)
  37         self.bind_resolvers_to_graphql_type(graphql_type)
  38 
  39     def validate_graphql_type(self, graphql_type: Optional[GraphQLNamedType]) -> None:
  40         if not graphql_type:
  41             raise ValueError("Type %s is not defined in the schema" % self.name)
  42         if not isinstance(graphql_type, GraphQLObjectType):
  43             raise ValueError(
  44                 "%s is defined in the schema, but it is instance of %s (expected %s)"
  45                 % (self.name, type(graphql_type).__name__, GraphQLObjectType.__name__)
  46             )
  47 
  48     def bind_resolvers_to_graphql_type(self, graphql_type, replace_existing=True):
  49         for field, resolver in self._resolvers.items():
  50             if field not in graphql_type.fields:
  51                 raise ValueError(
  52                     "Field %s is not defined on type %s" % (field, self.name)
  53                 )
  54             if graphql_type.fields[field].resolve is None or replace_existing:
  55                 graphql_type.fields[field].resolve = resolver
  56 
  57 
  58 class QueryType(ObjectType):
  59     """Convenience class for defining Query type"""
  60 
  61     def __init__(self):
  62         super().__init__("Query")
  63 
  64 
  65 class MutationType(ObjectType):
  66     """Convenience class for defining Mutation type"""
  67 
  68     def __init__(self):
  69         super().__init__("Mutation")
  70
  [end of ariadne/objects.py]
  [start of ariadne/subscriptions.py]
  1 from typing import Callable, Dict
  2 
  3 from graphql.type import GraphQLSchema
  4 
  5 from .objects import ObjectType
  6 from .types import Subscriber
  7 
  8 
  9 class SubscriptionType(ObjectType):
  10     _subscribers: Dict[str, Subscriber]
  11 
  12     def __init__(self) -> None:
  13         super().__init__("Subscription")
  14         self._subscribers = {}
  15 
  16     def source(self, name: str) -> Callable[[Subscriber], Subscriber]:
  17         return self.create_register_subscriber(name)
  18 
  19     def create_register_subscriber(
  20         self, name: str
  21     ) -> Callable[[Subscriber], Subscriber]:
  22         def register_subscriber(generator: Subscriber) -> Subscriber:
  23             self._subscribers[name] = generator
  24             return generator
  25 
  26         return register_subscriber
  27 
  28     def set_source(self, name, generator: Subscriber) -> Subscriber:
  29         self._subscribers[name] = generator
  30         return generator
  31 
  32     def bind_to_schema(self, schema: GraphQLSchema) -> None:
  33         graphql_type = schema.type_map.get(self.name)
  34         self.validate_graphql_type(graphql_type)
  35         self.bind_resolvers_to_graphql_type(graphql_type)
  36         self.bind_subscribers_to_graphql_type(graphql_type)
  37 
  38     def bind_subscribers_to_graphql_type(self, graphql_type):
  39         for field, subscriber in self._subscribers.items():
  40             if field not in graphql_type.fields:
  41                 raise ValueError(
  42                     "Field %s is not defined on type %s" % (field, self.name)
  43                 )
  44 
  45             graphql_type.fields[field].subscribe = subscriber
  46
  [end of ariadne/subscriptions.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/ariadne/objects.py b/ariadne/objects.py
  --- a/ariadne/objects.py
  +++ b/ariadne/objects.py
  @@ -14,6 +14,10 @@
           self._resolvers = {}
   
       def field(self, name: str) -> Callable[[Resolver], Resolver]:
  +        if not isinstance(name, str):
  +            raise ValueError(
  +                'field decorator should be passed a field name: @foo.field("name")'
  +            )
           return self.create_register_resolver(name)
   
       def create_register_resolver(self, name: str) -> Callable[[Resolver], Resolver]:
  diff --git a/ariadne/subscriptions.py b/ariadne/subscriptions.py
  --- a/ariadne/subscriptions.py
  +++ b/ariadne/subscriptions.py
  @@ -14,6 +14,10 @@
           self._subscribers = {}
   
       def source(self, name: str) -> Callable[[Subscriber], Subscriber]:
  +        if not isinstance(name, str):
  +            raise ValueError(
  +                'source decorator should be passed a field name: @foo.source("name")'
  +            )
           return self.create_register_subscriber(name)
   
       def create_register_subscriber(
  
verification_info: {"golden_diff": "diff --git a/ariadne/objects.py b/ariadne/objects.py\n--- a/ariadne/objects.py\n+++ b/ariadne/objects.py\n@@ -14,6 +14,10 @@\n         self._resolvers = {}\n \n     def field(self, name: str) -> Callable[[Resolver], Resolver]:\n+        if not isinstance(name, str):\n+            raise ValueError(\n+                'field decorator should be passed a field name: @foo.field(\"name\")'\n+            )\n         return self.create_register_resolver(name)\n \n     def create_register_resolver(self, name: str) -> Callable[[Resolver], Resolver]:\ndiff --git a/ariadne/subscriptions.py b/ariadne/subscriptions.py\n--- a/ariadne/subscriptions.py\n+++ b/ariadne/subscriptions.py\n@@ -14,6 +14,10 @@\n         self._subscribers = {}\n \n     def source(self, name: str) -> Callable[[Subscriber], Subscriber]:\n+        if not isinstance(name, str):\n+            raise ValueError(\n+                'source decorator should be passed a field name: @foo.source(\"name\")'\n+            )\n         return self.create_register_subscriber(name)\n \n     def create_register_subscriber(\n", "issue": "Raise ValueError when `field` or `source` decorator was called incorrectly\nCurrently there's no error when the developer forgets to follow the `field` or `source` decorator with `(\"name\")`, tricking them into thinking that decorated function has been registered while in fact it wasn't.\r\n\r\nWe could update implementation for those functions to raise ValueError when `name` attr is not `str`.\n", "before_files": [{"content": "from typing import Callable, Dict, Optional, cast\n\nfrom graphql.type import GraphQLNamedType, GraphQLObjectType, GraphQLSchema\n\nfrom .resolvers import resolve_to\nfrom .types import Resolver, SchemaBindable\n\n\nclass ObjectType(SchemaBindable):\n    _resolvers: Dict[str, Resolver]\n\n    def __init__(self, name: str) -> None:\n        self.name = name\n        self._resolvers = {}\n\n    def field(self, name: str) -> Callable[[Resolver], Resolver]:\n        return self.create_register_resolver(name)\n\n    def create_register_resolver(self, name: str) -> Callable[[Resolver], Resolver]:\n        def register_resolver(f: Resolver) -> Resolver:\n            self._resolvers[name] = f\n            return f\n\n        return register_resolver\n\n    def set_field(self, name, resolver: Resolver) -> Resolver:\n        self._resolvers[name] = resolver\n        return resolver\n\n    def set_alias(self, name: str, to: str) -> None:\n        self._resolvers[name] = resolve_to(to)\n\n    def bind_to_schema(self, schema: GraphQLSchema) -> None:\n        graphql_type = schema.type_map.get(self.name)\n        self.validate_graphql_type(graphql_type)\n        graphql_type = cast(GraphQLObjectType, graphql_type)\n        self.bind_resolvers_to_graphql_type(graphql_type)\n\n    def validate_graphql_type(self, graphql_type: Optional[GraphQLNamedType]) -> None:\n        if not graphql_type:\n            raise ValueError(\"Type %s is not defined in the schema\" % self.name)\n        if not isinstance(graphql_type, GraphQLObjectType):\n            raise ValueError(\n                \"%s is defined in the schema, but it is instance of %s (expected %s)\"\n                % (self.name, type(graphql_type).__name__, GraphQLObjectType.__name__)\n            )\n\n    def bind_resolvers_to_graphql_type(self, graphql_type, replace_existing=True):\n        for field, resolver in self._resolvers.items():\n            if field not in graphql_type.fields:\n                raise ValueError(\n                    \"Field %s is not defined on type %s\" % (field, self.name)\n                )\n            if graphql_type.fields[field].resolve is None or replace_existing:\n                graphql_type.fields[field].resolve = resolver\n\n\nclass QueryType(ObjectType):\n    \"\"\"Convenience class for defining Query type\"\"\"\n\n    def __init__(self):\n        super().__init__(\"Query\")\n\n\nclass MutationType(ObjectType):\n    \"\"\"Convenience class for defining Mutation type\"\"\"\n\n    def __init__(self):\n        super().__init__(\"Mutation\")\n", "path": "ariadne/objects.py"}, {"content": "from typing import Callable, Dict\n\nfrom graphql.type import GraphQLSchema\n\nfrom .objects import ObjectType\nfrom .types import Subscriber\n\n\nclass SubscriptionType(ObjectType):\n    _subscribers: Dict[str, Subscriber]\n\n    def __init__(self) -> None:\n        super().__init__(\"Subscription\")\n        self._subscribers = {}\n\n    def source(self, name: str) -> Callable[[Subscriber], Subscriber]:\n        return self.create_register_subscriber(name)\n\n    def create_register_subscriber(\n        self, name: str\n    ) -> Callable[[Subscriber], Subscriber]:\n        def register_subscriber(generator: Subscriber) -> Subscriber:\n            self._subscribers[name] = generator\n            return generator\n\n        return register_subscriber\n\n    def set_source(self, name, generator: Subscriber) -> Subscriber:\n        self._subscribers[name] = generator\n        return generator\n\n    def bind_to_schema(self, schema: GraphQLSchema) -> None:\n        graphql_type = schema.type_map.get(self.name)\n        self.validate_graphql_type(graphql_type)\n        self.bind_resolvers_to_graphql_type(graphql_type)\n        self.bind_subscribers_to_graphql_type(graphql_type)\n\n    def bind_subscribers_to_graphql_type(self, graphql_type):\n        for field, subscriber in self._subscribers.items():\n            if field not in graphql_type.fields:\n                raise ValueError(\n                    \"Field %s is not defined on type %s\" % (field, self.name)\n                )\n\n            graphql_type.fields[field].subscribe = subscriber\n", "path": "ariadne/subscriptions.py"}]}