We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
`hypothesis --version` does not work
When I use `pip install hypothesis` in a clear env and run `hypothesis --version`, this happens:

```python
» hypothesis --version
Traceback (most recent call last):
  File "/Users/sobolev/Documents/github/returns/.venv/bin/hypothesis", line 6, in <module>
    from hypothesis.extra.cli import main
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/hypothesis/extra/cli.py", line 35, in <module>
    from hypothesis.extra import ghostwriter
  File "/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/hypothesis/extra/ghostwriter.py", line 57, in <module>
    import black
ModuleNotFoundError: No module named 'black'
```

Looks like `black` is treated as a required dependency right now.

After installing `black`:

```
» hypothesis --version
hypothesis, version 5.33.0
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `hypothesis-python/src/hypothesis/extra/cli.py`
Content:
```
1 # This file is part of Hypothesis, which may be found at
2 # https://github.com/HypothesisWorks/hypothesis/
3 #
4 # Most of this work is copyright (C) 2013-2020 David R. MacIver
5 # (david@drmaciver.com), but it contains contributions by others. See
6 # CONTRIBUTING.rst for a full list of people who may hold copyright, and
7 # consult the git log if you need to determine who owns an individual
8 # contribution.
9 #
10 # This Source Code Form is subject to the terms of the Mozilla Public License,
11 # v. 2.0. If a copy of the MPL was not distributed with this file, You can
12 # obtain one at https://mozilla.org/MPL/2.0/.
13 #
14 # END HEADER
15 
16 """
17 .. _hypothesis-cli:
18 
19 ----------------
20 hypothesis[cli]
21 ----------------
22 
23 This module provides Hypothesis' command-line interface, for e.g.
24 :doc:`'ghostwriting' tests <ghostwriter>` via the terminal.
25 It requires the :pypi:`click` package.
26 
27 Run :command:`hypothesis --help` in your terminal for details.
28 """
29 
30 import builtins
31 import importlib
32 import sys
33 from difflib import get_close_matches
34 
35 from hypothesis.extra import ghostwriter
36 
37 try:
38     import click
39 except ImportError:
40 
41     def main():
42         """If `click` is not installed, tell the user to install it then exit."""
43         sys.stderr.write(
44             """
45 The Hypothesis command-line interface requires the `click` package,
46 which you do not have installed.  Run:
47 
48     python -m pip install --upgrade hypothesis[cli]
49 
50 and try again.
51 """
52         )
53         sys.exit(1)
54 
55 
56 else:
57     # Ensure that Python scripts in the current working directory are importable,
58     # on the principle that Ghostwriter should 'just work' for novice users.  Note
59     # that we append rather than prepend to the module search path, so this will
60     # never shadow the stdlib or installed packages.
61     sys.path.append(".")
62 
63     @click.group(context_settings={"help_option_names": ("-h", "--help")})
64     @click.version_option()
65     def main():
66         pass
67 
68     def obj_name(s: str) -> object:
69         """This "type" imports whatever object is named by a dotted string."""
70         s = s.strip()
71         try:
72             return importlib.import_module(s)
73         except ImportError:
74             pass
75         if "." not in s:
76             modulename, module, funcname = "builtins", builtins, s
77         else:
78             modulename, funcname = s.rsplit(".", 1)
79             try:
80                 module = importlib.import_module(modulename)
81             except ImportError:
82                 raise click.UsageError(
83                     f"Failed to import the {modulename} module for introspection.  "
84                     "Check spelling and your Python import path, or use the Python API?"
85                 )
86         try:
87             return getattr(module, funcname)
88         except AttributeError:
89             public_names = [name for name in vars(module) if not name.startswith("_")]
90             matches = get_close_matches(funcname, public_names)
91             raise click.UsageError(
92                 f"Found the {modulename!r} module, but it doesn't have a "
93                 f"{funcname!r} attribute."
94                 + (f"  Closest matches: {matches!r}" if matches else "")
95             )
96 
97     @main.command()  # type: ignore  # Click adds the .command attribute
98     @click.argument("func", type=obj_name, required=True, nargs=-1)
99     @click.option("--idempotent", "writer", flag_value="idempotent")
100     @click.option("--binary-op", "writer", flag_value="binary_operation")
101     @click.option("--equivalent", "writer", flag_value="equivalent")
102     @click.option("--roundtrip", "writer", flag_value="roundtrip")
103     # Note: we deliberately omit a --ufunc flag, because the magic()
104     # detection of ufuncs is both precise and complete.
105     @click.option(
106         "--style",
107         type=click.Choice(["pytest", "unittest"]),
108         default="pytest",
109         help="pytest-style function, or unittest-style method?",
110     )
111     @click.option(
112         "-e",
113         "--except",
114         "except_",
115         type=obj_name,
116         multiple=True,
117         help="dotted name of exception(s) to ignore",
118     )
119     def write(func, writer, except_, style):  # noqa: D301  # \b disables autowrap
120         """`hypothesis write` writes property-based tests for you!
121 
122         Type annotations are helpful but not required for our advanced introspection
123         and templating logic.  Try running the examples below to see how it works:
124 
125         \b
126             hypothesis write gzip
127             hypothesis write re.compile --except re.error
128             hypothesis write --style=unittest --idempotent sorted
129             hypothesis write --binary-op operator.add
130             hypothesis write --equivalent ast.literal_eval eval
131             hypothesis write --roundtrip json.dumps json.loads
132         """
133         # NOTE: if you want to call this function from Python, look instead at the
134         # ``hypothesis.extra.ghostwriter`` module.  Click-decorated functions have
135         # a different calling convention, and raise SystemExit instead of returning.
136         if writer is None:
137             writer = "magic"
138         elif writer == "idempotent" and len(func) > 1:
139             raise click.UsageError("Test functions for idempotence one at a time.")
140         elif writer == "roundtrip" and len(func) == 1:
141             writer = "idempotent"
142         elif writer == "equivalent" and len(func) == 1:
143             writer = "fuzz"
144 
145         print(getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style))
146
```
--- 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/hypothesis-python/src/hypothesis/extra/cli.py b/hypothesis-python/src/hypothesis/extra/cli.py
--- a/hypothesis-python/src/hypothesis/extra/cli.py
+++ b/hypothesis-python/src/hypothesis/extra/cli.py
@@ -32,7 +32,14 @@
 import sys
 from difflib import get_close_matches
 
-from hypothesis.extra import ghostwriter
+MESSAGE = """
+The Hypothesis command-line interface requires the `{}` package,
+which you do not have installed.  Run:
+
+    python -m pip install --upgrade hypothesis[cli]
+
+and try again.
+"""
 
 try:
     import click
@@ -40,16 +47,7 @@
 
     def main():
         """If `click` is not installed, tell the user to install it then exit."""
-        sys.stderr.write(
-            """
-The Hypothesis command-line interface requires the `click` package,
-which you do not have installed.  Run:
-
-    python -m pip install --upgrade hypothesis[cli]
-
-and try again.
-"""
-        )
+        sys.stderr.write(MESSAGE.format("click"))
         sys.exit(1)
 
 
@@ -142,4 +140,10 @@
         elif writer == "equivalent" and len(func) == 1:
             writer = "fuzz"
 
+        try:
+            from hypothesis.extra import ghostwriter
+        except ImportError:
+            sys.stderr.write(MESSAGE.format("black"))
+            sys.exit(1)
+
         print(getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style))

{"golden_diff": "diff --git a/hypothesis-python/src/hypothesis/extra/cli.py b/hypothesis-python/src/hypothesis/extra/cli.py\n--- a/hypothesis-python/src/hypothesis/extra/cli.py\n+++ b/hypothesis-python/src/hypothesis/extra/cli.py\n@@ -32,7 +32,14 @@\n import sys\n from difflib import get_close_matches\n \n-from hypothesis.extra import ghostwriter\n+MESSAGE = \"\"\"\n+The Hypothesis command-line interface requires the `{}` package,\n+which you do not have installed.  Run:\n+\n+    python -m pip install --upgrade hypothesis[cli]\n+\n+and try again.\n+\"\"\"\n \n try:\n     import click\n@@ -40,16 +47,7 @@\n \n     def main():\n         \"\"\"If `click` is not installed, tell the user to install it then exit.\"\"\"\n-        sys.stderr.write(\n-            \"\"\"\n-The Hypothesis command-line interface requires the `click` package,\n-which you do not have installed.  Run:\n-\n-    python -m pip install --upgrade hypothesis[cli]\n-\n-and try again.\n-\"\"\"\n-        )\n+        sys.stderr.write(MESSAGE.format(\"click\"))\n         sys.exit(1)\n \n \n@@ -142,4 +140,10 @@\n         elif writer == \"equivalent\" and len(func) == 1:\n             writer = \"fuzz\"\n \n+        try:\n+            from hypothesis.extra import ghostwriter\n+        except ImportError:\n+            sys.stderr.write(MESSAGE.format(\"black\"))\n+            sys.exit(1)\n+\n         print(getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style))\n", "issue": "`hypothesis --version` does not work\nWhen I use `pip install hypothesis` in a clear env and run `hypothesis --version`, this happens:\r\n\r\n```python\r\n\u00bb hypothesis --version\r\nTraceback (most recent call last):\r\n  File \"/Users/sobolev/Documents/github/returns/.venv/bin/hypothesis\", line 6, in <module>\r\n    from hypothesis.extra.cli import main\r\n  File \"/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/hypothesis/extra/cli.py\", line 35, in <module>\r\n    from hypothesis.extra import ghostwriter\r\n  File \"/Users/sobolev/Documents/github/returns/.venv/lib/python3.7/site-packages/hypothesis/extra/ghostwriter.py\", line 57, in <module>\r\n    import black\r\nModuleNotFoundError: No module named 'black'\r\n```\r\n\r\nLooks like `black` is treated as a required dependency right now.\r\n\r\nAfter installing `black`:\r\n\r\n```\r\n\u00bb hypothesis --version\r\nhypothesis, version 5.33.0\r\n```\n", "before_files": [{"content": "# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis/\n#\n# Most of this work is copyright (C) 2013-2020 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at https://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\n\"\"\"\n.. _hypothesis-cli:\n\n----------------\nhypothesis[cli]\n----------------\n\nThis module provides Hypothesis' command-line interface, for e.g.\n:doc:`'ghostwriting' tests <ghostwriter>` via the terminal.\nIt requires the :pypi:`click` package.\n\nRun :command:`hypothesis --help` in your terminal for details.\n\"\"\"\n\nimport builtins\nimport importlib\nimport sys\nfrom difflib import get_close_matches\n\nfrom hypothesis.extra import ghostwriter\n\ntry:\n    import click\nexcept ImportError:\n\n    def main():\n        \"\"\"If `click` is not installed, tell the user to install it then exit.\"\"\"\n        sys.stderr.write(\n            \"\"\"\nThe Hypothesis command-line interface requires the `click` package,\nwhich you do not have installed.  Run:\n\n    python -m pip install --upgrade hypothesis[cli]\n\nand try again.\n\"\"\"\n        )\n        sys.exit(1)\n\n\nelse:\n    # Ensure that Python scripts in the current working directory are importable,\n    # on the principle that Ghostwriter should 'just work' for novice users.  Note\n    # that we append rather than prepend to the module search path, so this will\n    # never shadow the stdlib or installed packages.\n    sys.path.append(\".\")\n\n    @click.group(context_settings={\"help_option_names\": (\"-h\", \"--help\")})\n    @click.version_option()\n    def main():\n        pass\n\n    def obj_name(s: str) -> object:\n        \"\"\"This \"type\" imports whatever object is named by a dotted string.\"\"\"\n        s = s.strip()\n        try:\n            return importlib.import_module(s)\n        except ImportError:\n            pass\n        if \".\" not in s:\n            modulename, module, funcname = \"builtins\", builtins, s\n        else:\n            modulename, funcname = s.rsplit(\".\", 1)\n            try:\n                module = importlib.import_module(modulename)\n            except ImportError:\n                raise click.UsageError(\n                    f\"Failed to import the {modulename} module for introspection.  \"\n                    \"Check spelling and your Python import path, or use the Python API?\"\n                )\n        try:\n            return getattr(module, funcname)\n        except AttributeError:\n            public_names = [name for name in vars(module) if not name.startswith(\"_\")]\n            matches = get_close_matches(funcname, public_names)\n            raise click.UsageError(\n                f\"Found the {modulename!r} module, but it doesn't have a \"\n                f\"{funcname!r} attribute.\"\n                + (f\"  Closest matches: {matches!r}\" if matches else \"\")\n            )\n\n    @main.command()  # type: ignore  # Click adds the .command attribute\n    @click.argument(\"func\", type=obj_name, required=True, nargs=-1)\n    @click.option(\"--idempotent\", \"writer\", flag_value=\"idempotent\")\n    @click.option(\"--binary-op\", \"writer\", flag_value=\"binary_operation\")\n    @click.option(\"--equivalent\", \"writer\", flag_value=\"equivalent\")\n    @click.option(\"--roundtrip\", \"writer\", flag_value=\"roundtrip\")\n    # Note: we deliberately omit a --ufunc flag, because the magic()\n    # detection of ufuncs is both precise and complete.\n    @click.option(\n        \"--style\",\n        type=click.Choice([\"pytest\", \"unittest\"]),\n        default=\"pytest\",\n        help=\"pytest-style function, or unittest-style method?\",\n    )\n    @click.option(\n        \"-e\",\n        \"--except\",\n        \"except_\",\n        type=obj_name,\n        multiple=True,\n        help=\"dotted name of exception(s) to ignore\",\n    )\n    def write(func, writer, except_, style):  # noqa: D301  # \\b disables autowrap\n        \"\"\"`hypothesis write` writes property-based tests for you!\n\n        Type annotations are helpful but not required for our advanced introspection\n        and templating logic.  Try running the examples below to see how it works:\n\n        \\b\n            hypothesis write gzip\n            hypothesis write re.compile --except re.error\n            hypothesis write --style=unittest --idempotent sorted\n            hypothesis write --binary-op operator.add\n            hypothesis write --equivalent ast.literal_eval eval\n            hypothesis write --roundtrip json.dumps json.loads\n        \"\"\"\n        # NOTE: if you want to call this function from Python, look instead at the\n        # ``hypothesis.extra.ghostwriter`` module.  Click-decorated functions have\n        # a different calling convention, and raise SystemExit instead of returning.\n        if writer is None:\n            writer = \"magic\"\n        elif writer == \"idempotent\" and len(func) > 1:\n            raise click.UsageError(\"Test functions for idempotence one at a time.\")\n        elif writer == \"roundtrip\" and len(func) == 1:\n            writer = \"idempotent\"\n        elif writer == \"equivalent\" and len(func) == 1:\n            writer = \"fuzz\"\n\n        print(getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style))\n", "path": "hypothesis-python/src/hypothesis/extra/cli.py"}], "after_files": [{"content": "# This file is part of Hypothesis, which may be found at\n# https://github.com/HypothesisWorks/hypothesis/\n#\n# Most of this work is copyright (C) 2013-2020 David R. MacIver\n# (david@drmaciver.com), but it contains contributions by others. See\n# CONTRIBUTING.rst for a full list of people who may hold copyright, and\n# consult the git log if you need to determine who owns an individual\n# contribution.\n#\n# This Source Code Form is subject to the terms of the Mozilla Public License,\n# v. 2.0. If a copy of the MPL was not distributed with this file, You can\n# obtain one at https://mozilla.org/MPL/2.0/.\n#\n# END HEADER\n\n\"\"\"\n.. _hypothesis-cli:\n\n----------------\nhypothesis[cli]\n----------------\n\nThis module provides Hypothesis' command-line interface, for e.g.\n:doc:`'ghostwriting' tests <ghostwriter>` via the terminal.\nIt requires the :pypi:`click` package.\n\nRun :command:`hypothesis --help` in your terminal for details.\n\"\"\"\n\nimport builtins\nimport importlib\nimport sys\nfrom difflib import get_close_matches\n\nMESSAGE = \"\"\"\nThe Hypothesis command-line interface requires the `{}` package,\nwhich you do not have installed.  Run:\n\n    python -m pip install --upgrade hypothesis[cli]\n\nand try again.\n\"\"\"\n\ntry:\n    import click\nexcept ImportError:\n\n    def main():\n        \"\"\"If `click` is not installed, tell the user to install it then exit.\"\"\"\n        sys.stderr.write(MESSAGE.format(\"click\"))\n        sys.exit(1)\n\n\nelse:\n    # Ensure that Python scripts in the current working directory are importable,\n    # on the principle that Ghostwriter should 'just work' for novice users.  Note\n    # that we append rather than prepend to the module search path, so this will\n    # never shadow the stdlib or installed packages.\n    sys.path.append(\".\")\n\n    @click.group(context_settings={\"help_option_names\": (\"-h\", \"--help\")})\n    @click.version_option()\n    def main():\n        pass\n\n    def obj_name(s: str) -> object:\n        \"\"\"This \"type\" imports whatever object is named by a dotted string.\"\"\"\n        s = s.strip()\n        try:\n            return importlib.import_module(s)\n        except ImportError:\n            pass\n        if \".\" not in s:\n            modulename, module, funcname = \"builtins\", builtins, s\n        else:\n            modulename, funcname = s.rsplit(\".\", 1)\n            try:\n                module = importlib.import_module(modulename)\n            except ImportError:\n                raise click.UsageError(\n                    f\"Failed to import the {modulename} module for introspection.  \"\n                    \"Check spelling and your Python import path, or use the Python API?\"\n                )\n        try:\n            return getattr(module, funcname)\n        except AttributeError:\n            public_names = [name for name in vars(module) if not name.startswith(\"_\")]\n            matches = get_close_matches(funcname, public_names)\n            raise click.UsageError(\n                f\"Found the {modulename!r} module, but it doesn't have a \"\n                f\"{funcname!r} attribute.\"\n                + (f\"  Closest matches: {matches!r}\" if matches else \"\")\n            )\n\n    @main.command()  # type: ignore  # Click adds the .command attribute\n    @click.argument(\"func\", type=obj_name, required=True, nargs=-1)\n    @click.option(\"--idempotent\", \"writer\", flag_value=\"idempotent\")\n    @click.option(\"--binary-op\", \"writer\", flag_value=\"binary_operation\")\n    @click.option(\"--equivalent\", \"writer\", flag_value=\"equivalent\")\n    @click.option(\"--roundtrip\", \"writer\", flag_value=\"roundtrip\")\n    # Note: we deliberately omit a --ufunc flag, because the magic()\n    # detection of ufuncs is both precise and complete.\n    @click.option(\n        \"--style\",\n        type=click.Choice([\"pytest\", \"unittest\"]),\n        default=\"pytest\",\n        help=\"pytest-style function, or unittest-style method?\",\n    )\n    @click.option(\n        \"-e\",\n        \"--except\",\n        \"except_\",\n        type=obj_name,\n        multiple=True,\n        help=\"dotted name of exception(s) to ignore\",\n    )\n    def write(func, writer, except_, style):  # noqa: D301  # \\b disables autowrap\n        \"\"\"`hypothesis write` writes property-based tests for you!\n\n        Type annotations are helpful but not required for our advanced introspection\n        and templating logic.  Try running the examples below to see how it works:\n\n        \\b\n            hypothesis write gzip\n            hypothesis write re.compile --except re.error\n            hypothesis write --style=unittest --idempotent sorted\n            hypothesis write --binary-op operator.add\n            hypothesis write --equivalent ast.literal_eval eval\n            hypothesis write --roundtrip json.dumps json.loads\n        \"\"\"\n        # NOTE: if you want to call this function from Python, look instead at the\n        # ``hypothesis.extra.ghostwriter`` module.  Click-decorated functions have\n        # a different calling convention, and raise SystemExit instead of returning.\n        if writer is None:\n            writer = \"magic\"\n        elif writer == \"idempotent\" and len(func) > 1:\n            raise click.UsageError(\"Test functions for idempotence one at a time.\")\n        elif writer == \"roundtrip\" and len(func) == 1:\n            writer = \"idempotent\"\n        elif writer == \"equivalent\" and len(func) == 1:\n            writer = \"fuzz\"\n\n        try:\n            from hypothesis.extra import ghostwriter\n        except ImportError:\n            sys.stderr.write(MESSAGE.format(\"black\"))\n            sys.exit(1)\n\n        print(getattr(ghostwriter, writer)(*func, except_=except_ or (), style=style))\n", "path": "hypothesis-python/src/hypothesis/extra/cli.py"}]}