Repository: encode/uvicorn

Issue:
TypeError: __init__() when run "uvicorn app:App"
I'm working on Mac Os Sierra 10.12.6, python 3.7.2 and uvicorn via pip3 0.5.1.
When I run the example uvicorn app:App get the following error:
Traceback (most recent call last):
  File "/usr/local/bin/uvicorn", line 11, in <module>
    load_entry_point('uvicorn==0.5.1', 'console_scripts', 'uvicorn')()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.7/site-packages/uvicorn/__init__.py", line 2, in <module>
    from uvicorn.main import Server, main, run
  File "/usr/local/lib/python3.7/site-packages/uvicorn/main.py", line 212, in <module>
    ssl_ciphers: str,
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 170, in decorator
    _param_memo(f, OptionClass(param_decls, **attrs))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1460, in __init__
    Parameter.__init__(self, param_decls, type=type, **attrs)
TypeError: __init__() got an unexpected keyword argument 'hidden'

Thank you


Discussion:
@adriangallegos Not a maintainer, but I think providing a minimum example application and full command listing allowing to reproduce this error would help people to help you. :-)
Thank you @florimondmanca 

I tried with the example:

class App():
    def __init__(self, scope):
        assert scope['type'] == 'http'
        self.scope = scope
    async def __call__(self, receive, send):
        await send({
            'type': 'http.response.start',
            'status': 200,
            'headers': [
                [b'content-type', b'text/plain'],
            ]
        })
        await send({
            'type': 'http.response.body',
            'body': b'Hello, world!',
        })

I then run uvicorn app:App

Thanks in advance !!!
Ah right, I didn't realise it was the example app from the [quickstart](https://www.uvicorn.org/#quickstart).

On my end, I'm able to run this without issues. I have the same config as yours except the macOS version (I have 10.14).

The traceback suggests this is an issue with `click`. I notice uvicorn's `setup.py` doesn't pin any minimal version for `click`, and you seem to use a global installation of `uvicorn` here. Did you already have `click` installed? Which version is it? Maybe try upgrading it via `pip install -U click`?
Thank you @florimondmanca. It's works !!!

I've version 6.7 and now 7.0

Thanks !!! 

Cool! I've tried using `click==6.7` and I was able to reproduce this bug.

After inspecting the source code in `main.py`, this comes from the `--debug` option that uses `hidden=True`. The `hidden` parameter is only available for Click 7+ and can be used to "hide the option from help outputs" (see the [Option API reference](http://click.palletsprojects.com/en/7.x/api/#click.Option)).

Not sure why we'd want to hide `--debug` from `--help`, but if this needs to stay then uvicorn should probably pin Click to `>=7`.
> Not sure why we'd want to hide --debug from --help

Because —reload is what we want to recommend. Debug should be an application-level setting, and we’ll deprecate I here.

> but if this needs to stay then uvicorn should probably pin Click to >=7.

Yup we need to do that.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -41,11 +41,11 @@ def get_packages(package):
 )
 
 requirements = [
-    "click",
-    "h11",
-    "websockets>=6.0",
-    "httptools;" + env_marker,
-    "uvloop;" + env_marker,
+    "click==7.*",
+    "h11==0.8.*",
+    "websockets==7.*",
+    "httptools==0.0.13 ;" + env_marker,
+    "uvloop==0.12.* ;" + env_marker,
 ]
 
 


Test patch: