We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
__ne__ doesn't allow returning NotImplemented
It seems that mypy doesn't allow `__ne__` returning `NotImplemented`, (this is allowed with `__eq__`).
And when I try explicitly adding `NotImplemented` as a possible return type, I get a run-time error:
```
  File ".../pod.py", line 65, in PlainOldData
    def __ne__(self, other: Any) -> Union[bool, NotImplemented]:
  File "/usr/lib/python3.6/typing.py", line 682, in inner
    return func(*args, **kwds)
  File "/usr/lib/python3.6/typing.py", line 800, in __getitem__
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/lib/python3.6/typing.py", line 800, in <genexpr>
    parameters = tuple(_type_check(p, msg) for p in parameters)
  File "/usr/lib/python3.6/typing.py", line 374, in _type_check
    raise TypeError(msg + " Got %.100r." % (arg,))
TypeError: Union[arg, ...]: each arg must be a type. Got NotImplemented.
```

If I change this to `def __ne__(self, other: Any) -> Union[bool, type(NotImplemented)]:`, then mypy complains: 
```
error: invalid type comment or annotation
note: Suggestion: use type[...] instead of type(...)
```

and when I try using this suggestion, I get a runtime error:
```
TypeError: 'type' object is not subscriptable
```

@gvanrossum  suggested (in [issue 1101](https://github.com/python/mypy/issues/1101#issuecomment-374685779)) that this was due to `__ne__` not being in `sharedparse.__MAGICMETHODS`; but it does appear to be there.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mypy/sharedparse.py`
Content:
```
1 from typing import Optional
2 
3 """Shared logic between our three mypy parser files."""
4 
5 
6 MAGIC_METHODS = {
7     "__abs__",
8     "__add__",
9     "__and__",
10     "__call__",
11     "__cmp__",
12     "__complex__",
13     "__contains__",
14     "__del__",
15     "__delattr__",
16     "__delitem__",
17     "__divmod__",
18     "__div__",
19     "__enter__",
20     "__exit__",
21     "__eq__",
22     "__floordiv__",
23     "__float__",
24     "__ge__",
25     "__getattr__",
26     "__getattribute__",
27     "__getitem__",
28     "__gt__",
29     "__hex__",
30     "__iadd__",
31     "__iand__",
32     "__idiv__",
33     "__ifloordiv__",
34     "__ilshift__",
35     "__imod__",
36     "__imul__",
37     "__init__",
38     "__init_subclass__",
39     "__int__",
40     "__invert__",
41     "__ior__",
42     "__ipow__",
43     "__irshift__",
44     "__isub__",
45     "__iter__",
46     "__ixor__",
47     "__le__",
48     "__len__",
49     "__long__",
50     "__lshift__",
51     "__lt__",
52     "__mod__",
53     "__mul__",
54     "__ne__",
55     "__neg__",
56     "__new__",
57     "__nonzero__",
58     "__oct__",
59     "__or__",
60     "__pos__",
61     "__pow__",
62     "__radd__",
63     "__rand__",
64     "__rdiv__",
65     "__repr__",
66     "__reversed__",
67     "__rfloordiv__",
68     "__rlshift__",
69     "__rmod__",
70     "__rmul__",
71     "__ror__",
72     "__rpow__",
73     "__rrshift__",
74     "__rshift__",
75     "__rsub__",
76     "__rxor__",
77     "__setattr__",
78     "__setitem__",
79     "__str__",
80     "__sub__",
81     "__unicode__",
82     "__xor__",
83 }
84 
85 MAGIC_METHODS_ALLOWING_KWARGS = {
86     "__init__",
87     "__init_subclass__",
88     "__new__",
89     "__call__",
90 }
91 
92 MAGIC_METHODS_POS_ARGS_ONLY = MAGIC_METHODS - MAGIC_METHODS_ALLOWING_KWARGS
93 
94 BINARY_MAGIC_METHODS = {
95     "__add__",
96     "__and__",
97     "__cmp__",
98     "__divmod__",
99     "__div__",
100     "__eq__",
101     "__floordiv__",
102     "__ge__",
103     "__gt__",
104     "__iadd__",
105     "__iand__",
106     "__idiv__",
107     "__ifloordiv__",
108     "__ilshift__",
109     "__imod__",
110     "__imul__",
111     "__ior__",
112     "__ipow__",
113     "__irshift__",
114     "__isub__",
115     "__ixor__",
116     "__le__",
117     "__lshift__",
118     "__lt__",
119     "__mod__",
120     "__mul__",
121     "__or__",
122     "__pow__",
123     "__radd__",
124     "__rand__",
125     "__rdiv__",
126     "__rfloordiv__",
127     "__rlshift__",
128     "__rmod__",
129     "__rmul__",
130     "__ror__",
131     "__rpow__",
132     "__rrshift__",
133     "__rshift__",
134     "__rsub__",
135     "__rxor__",
136     "__sub__",
137     "__xor__",
138 }
139 
140 
141 def special_function_elide_names(name: str) -> bool:
142     return name in MAGIC_METHODS_POS_ARGS_ONLY
143 
144 
145 def argument_elide_name(name: Optional[str]) -> bool:
146     return name is not None and name.startswith("__")
147
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mypy/sharedparse.py b/mypy/sharedparse.py
--- a/mypy/sharedparse.py
+++ b/mypy/sharedparse.py
@@ -118,6 +118,7 @@
     "__lt__",
     "__mod__",
     "__mul__",
+    "__ne__",
     "__or__",
     "__pow__",
     "__radd__",

{"golden_diff": "diff --git a/mypy/sharedparse.py b/mypy/sharedparse.py\n--- a/mypy/sharedparse.py\n+++ b/mypy/sharedparse.py\n@@ -118,6 +118,7 @@\n     \"__lt__\",\n     \"__mod__\",\n     \"__mul__\",\n+    \"__ne__\",\n     \"__or__\",\n     \"__pow__\",\n     \"__radd__\",\n", "issue": "__ne__ doesn't allow returning NotImplemented\nIt seems that mypy doesn't allow `__ne__` returning `NotImplemented`, (this is allowed with `__eq__`).\r\nAnd when I try explicitly adding `NotImplemented` as a possible return type, I get a run-time error:\r\n```\r\n  File \".../pod.py\", line 65, in PlainOldData\r\n    def __ne__(self, other: Any) -> Union[bool, NotImplemented]:\r\n  File \"/usr/lib/python3.6/typing.py\", line 682, in inner\r\n    return func(*args, **kwds)\r\n  File \"/usr/lib/python3.6/typing.py\", line 800, in __getitem__\r\n    parameters = tuple(_type_check(p, msg) for p in parameters)\r\n  File \"/usr/lib/python3.6/typing.py\", line 800, in <genexpr>\r\n    parameters = tuple(_type_check(p, msg) for p in parameters)\r\n  File \"/usr/lib/python3.6/typing.py\", line 374, in _type_check\r\n    raise TypeError(msg + \" Got %.100r.\" % (arg,))\r\nTypeError: Union[arg, ...]: each arg must be a type. Got NotImplemented.\r\n```\r\n\r\nIf I change this to `def __ne__(self, other: Any) -> Union[bool, type(NotImplemented)]:`, then mypy complains: \r\n```\r\nerror: invalid type comment or annotation\r\nnote: Suggestion: use type[...] instead of type(...)\r\n```\r\n\r\nand when I try using this suggestion, I get a runtime error:\r\n```\r\nTypeError: 'type' object is not subscriptable\r\n```\r\n\r\n@gvanrossum  suggested (in [issue 1101](https://github.com/python/mypy/issues/1101#issuecomment-374685779)) that this was due to `__ne__` not being in `sharedparse.__MAGICMETHODS`; but it does appear to be there.\r\n\n", "before_files": [{"content": "from typing import Optional\n\n\"\"\"Shared logic between our three mypy parser files.\"\"\"\n\n\nMAGIC_METHODS = {\n    \"__abs__\",\n    \"__add__\",\n    \"__and__\",\n    \"__call__\",\n    \"__cmp__\",\n    \"__complex__\",\n    \"__contains__\",\n    \"__del__\",\n    \"__delattr__\",\n    \"__delitem__\",\n    \"__divmod__\",\n    \"__div__\",\n    \"__enter__\",\n    \"__exit__\",\n    \"__eq__\",\n    \"__floordiv__\",\n    \"__float__\",\n    \"__ge__\",\n    \"__getattr__\",\n    \"__getattribute__\",\n    \"__getitem__\",\n    \"__gt__\",\n    \"__hex__\",\n    \"__iadd__\",\n    \"__iand__\",\n    \"__idiv__\",\n    \"__ifloordiv__\",\n    \"__ilshift__\",\n    \"__imod__\",\n    \"__imul__\",\n    \"__init__\",\n    \"__init_subclass__\",\n    \"__int__\",\n    \"__invert__\",\n    \"__ior__\",\n    \"__ipow__\",\n    \"__irshift__\",\n    \"__isub__\",\n    \"__iter__\",\n    \"__ixor__\",\n    \"__le__\",\n    \"__len__\",\n    \"__long__\",\n    \"__lshift__\",\n    \"__lt__\",\n    \"__mod__\",\n    \"__mul__\",\n    \"__ne__\",\n    \"__neg__\",\n    \"__new__\",\n    \"__nonzero__\",\n    \"__oct__\",\n    \"__or__\",\n    \"__pos__\",\n    \"__pow__\",\n    \"__radd__\",\n    \"__rand__\",\n    \"__rdiv__\",\n    \"__repr__\",\n    \"__reversed__\",\n    \"__rfloordiv__\",\n    \"__rlshift__\",\n    \"__rmod__\",\n    \"__rmul__\",\n    \"__ror__\",\n    \"__rpow__\",\n    \"__rrshift__\",\n    \"__rshift__\",\n    \"__rsub__\",\n    \"__rxor__\",\n    \"__setattr__\",\n    \"__setitem__\",\n    \"__str__\",\n    \"__sub__\",\n    \"__unicode__\",\n    \"__xor__\",\n}\n\nMAGIC_METHODS_ALLOWING_KWARGS = {\n    \"__init__\",\n    \"__init_subclass__\",\n    \"__new__\",\n    \"__call__\",\n}\n\nMAGIC_METHODS_POS_ARGS_ONLY = MAGIC_METHODS - MAGIC_METHODS_ALLOWING_KWARGS\n\nBINARY_MAGIC_METHODS = {\n    \"__add__\",\n    \"__and__\",\n    \"__cmp__\",\n    \"__divmod__\",\n    \"__div__\",\n    \"__eq__\",\n    \"__floordiv__\",\n    \"__ge__\",\n    \"__gt__\",\n    \"__iadd__\",\n    \"__iand__\",\n    \"__idiv__\",\n    \"__ifloordiv__\",\n    \"__ilshift__\",\n    \"__imod__\",\n    \"__imul__\",\n    \"__ior__\",\n    \"__ipow__\",\n    \"__irshift__\",\n    \"__isub__\",\n    \"__ixor__\",\n    \"__le__\",\n    \"__lshift__\",\n    \"__lt__\",\n    \"__mod__\",\n    \"__mul__\",\n    \"__or__\",\n    \"__pow__\",\n    \"__radd__\",\n    \"__rand__\",\n    \"__rdiv__\",\n    \"__rfloordiv__\",\n    \"__rlshift__\",\n    \"__rmod__\",\n    \"__rmul__\",\n    \"__ror__\",\n    \"__rpow__\",\n    \"__rrshift__\",\n    \"__rshift__\",\n    \"__rsub__\",\n    \"__rxor__\",\n    \"__sub__\",\n    \"__xor__\",\n}\n\n\ndef special_function_elide_names(name: str) -> bool:\n    return name in MAGIC_METHODS_POS_ARGS_ONLY\n\n\ndef argument_elide_name(name: Optional[str]) -> bool:\n    return name is not None and name.startswith(\"__\")\n", "path": "mypy/sharedparse.py"}], "after_files": [{"content": "from typing import Optional\n\n\"\"\"Shared logic between our three mypy parser files.\"\"\"\n\n\nMAGIC_METHODS = {\n    \"__abs__\",\n    \"__add__\",\n    \"__and__\",\n    \"__call__\",\n    \"__cmp__\",\n    \"__complex__\",\n    \"__contains__\",\n    \"__del__\",\n    \"__delattr__\",\n    \"__delitem__\",\n    \"__divmod__\",\n    \"__div__\",\n    \"__enter__\",\n    \"__exit__\",\n    \"__eq__\",\n    \"__floordiv__\",\n    \"__float__\",\n    \"__ge__\",\n    \"__getattr__\",\n    \"__getattribute__\",\n    \"__getitem__\",\n    \"__gt__\",\n    \"__hex__\",\n    \"__iadd__\",\n    \"__iand__\",\n    \"__idiv__\",\n    \"__ifloordiv__\",\n    \"__ilshift__\",\n    \"__imod__\",\n    \"__imul__\",\n    \"__init__\",\n    \"__init_subclass__\",\n    \"__int__\",\n    \"__invert__\",\n    \"__ior__\",\n    \"__ipow__\",\n    \"__irshift__\",\n    \"__isub__\",\n    \"__iter__\",\n    \"__ixor__\",\n    \"__le__\",\n    \"__len__\",\n    \"__long__\",\n    \"__lshift__\",\n    \"__lt__\",\n    \"__mod__\",\n    \"__mul__\",\n    \"__ne__\",\n    \"__neg__\",\n    \"__new__\",\n    \"__nonzero__\",\n    \"__oct__\",\n    \"__or__\",\n    \"__pos__\",\n    \"__pow__\",\n    \"__radd__\",\n    \"__rand__\",\n    \"__rdiv__\",\n    \"__repr__\",\n    \"__reversed__\",\n    \"__rfloordiv__\",\n    \"__rlshift__\",\n    \"__rmod__\",\n    \"__rmul__\",\n    \"__ror__\",\n    \"__rpow__\",\n    \"__rrshift__\",\n    \"__rshift__\",\n    \"__rsub__\",\n    \"__rxor__\",\n    \"__setattr__\",\n    \"__setitem__\",\n    \"__str__\",\n    \"__sub__\",\n    \"__unicode__\",\n    \"__xor__\",\n}\n\nMAGIC_METHODS_ALLOWING_KWARGS = {\n    \"__init__\",\n    \"__init_subclass__\",\n    \"__new__\",\n    \"__call__\",\n}\n\nMAGIC_METHODS_POS_ARGS_ONLY = MAGIC_METHODS - MAGIC_METHODS_ALLOWING_KWARGS\n\nBINARY_MAGIC_METHODS = {\n    \"__add__\",\n    \"__and__\",\n    \"__cmp__\",\n    \"__divmod__\",\n    \"__div__\",\n    \"__eq__\",\n    \"__floordiv__\",\n    \"__ge__\",\n    \"__gt__\",\n    \"__iadd__\",\n    \"__iand__\",\n    \"__idiv__\",\n    \"__ifloordiv__\",\n    \"__ilshift__\",\n    \"__imod__\",\n    \"__imul__\",\n    \"__ior__\",\n    \"__ipow__\",\n    \"__irshift__\",\n    \"__isub__\",\n    \"__ixor__\",\n    \"__le__\",\n    \"__lshift__\",\n    \"__lt__\",\n    \"__mod__\",\n    \"__mul__\",\n    \"__ne__\",\n    \"__or__\",\n    \"__pow__\",\n    \"__radd__\",\n    \"__rand__\",\n    \"__rdiv__\",\n    \"__rfloordiv__\",\n    \"__rlshift__\",\n    \"__rmod__\",\n    \"__rmul__\",\n    \"__ror__\",\n    \"__rpow__\",\n    \"__rrshift__\",\n    \"__rshift__\",\n    \"__rsub__\",\n    \"__rxor__\",\n    \"__sub__\",\n    \"__xor__\",\n}\n\n\ndef special_function_elide_names(name: str) -> bool:\n    return name in MAGIC_METHODS_POS_ARGS_ONLY\n\n\ndef argument_elide_name(name: Optional[str]) -> bool:\n    return name is not None and name.startswith(\"__\")\n", "path": "mypy/sharedparse.py"}]}