Repository: cookiecutter/cookiecutter

Issue:
prompt.read_user_dict() is broken due to click upgrade from 7.1.2 to 8.0.0
* Cookiecutter version: 1.7.3
* Template project url: -
* Python version: 3.9.5
* Operating System: macOS Catalina 10.15.7

### Description:

Apparently, there is a breaking change in `click==8.0.0` affecting dictionary values in cookiecutter.json
cookiecutter.json example:
```json
{
    "project_name": "",
    "project_policy": {"project_policy_example": "yes"}
}
```
 
```
% python -m cookiecutter ../Projects/project-configs
devplatform_project_name [infra-dev]: 
project_name []: t
project_policy [default]: 
Error: Unable to decode to JSON.
```

Looking closer at the cookiecutter.promt, I can see that in `read_user_dict()`, click passes `user_value='default'` to `process_json()`, instead of passing an actual default value from the cookiecutter.json as it was in `click 7.1.2`. 
Link to the `process_json()` code: https://github.com/cookiecutter/cookiecutter/blob/master/cookiecutter/prompt.py#L81
![image](https://user-images.githubusercontent.com/41152092/118825592-7a01bd80-b8c3-11eb-96fb-1f7bba264783.png)

As far as I can suppose, that issue could have been introduced by this PR https://github.com/pallets/click/pull/1517/

### Quick local fix
Install click first and specify version older than 8.0.0
```
pip install click==7.1.2
pip install cookiecutter
```

### Quick fix for cookiecutter library
in `setup.py` replace 'click>=7.0' with `'click>=7,<8.0.0'`

### What I've run:

```shell
% python3.9 -m venv test39              
  
% source test39/bin/activate

% python -V
Python 3.9.5


% python -m pip install click==7.1.2
Collecting click==7.1.2
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Installing collected packages: click
Successfully installed click-7.1.2
(test39) ro.solyanik@macbook-ro Environments % python -m pip install cookiecutter
Collecting cookiecutter
  Using cached cookiecutter-1.7.3-py2.py3-none-any.whl (34 kB)
Collecting six>=1.10
................................................
Installing collected packages: six, python-dateutil, MarkupSafe, urllib3, text-unidecode, Jinja2, idna, chardet, certifi, arrow, requests, python-slugify, poyo, jinja2-time, binaryornot, cookiecutter
Successfully installed Jinja2-3.0.1 MarkupSafe-2.0.1 arrow-1.1.0 binaryornot-0.4.4 certifi-2020.12.5 chardet-4.0.0 cookiecutter-1.7.3 idna-2.10 jinja2-time-0.2.0 poyo-0.5.0 python-dateutil-2.8.1 python-slugify-5.0.2 requests-2.25.1 six-1.16.0 text-unidecode-1.3 urllib3-1.26.4

% python -m cookiecutter ../Projects/project-configs
project_name []: t
project_policy [default]: 

% ls t  
Makefile        README.md       t               tests

% rm -rf t

% python -m pip install click==8.0.0                
Collecting click==8.0.0
  Using cached click-8.0.0-py3-none-any.whl (96 kB)
Installing collected packages: click
  Attempting uninstall: click
    Found existing installation: click 7.1.2
    Uninstalling click-7.1.2:
      Successfully uninstalled click-7.1.2
Successfully installed click-8.0.0

% python -m cookiecutter ../Projects/project-configs
devplatform_project_name [infra-dev]: 
project_name []: t
project_policy [default]: 
Error: Unable to decode to JSON.
project_policy [default]: 
Error: Unable to decode to JSON.
```


Discussion:
Good catch!
I think we should start pinning `click` asap on `master` and `stable/1.7.x`, then come up with a solution for the next major to support `click==8.x.x`

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@
 requirements = [
     'binaryornot>=0.4.4',
     'Jinja2>=2.7,<4.0.0',
-    'click>=7.0',
+    'click>=7.0,<8.0.0',
     'poyo>=0.5.0',
     'jinja2-time>=0.2.0',
     'python-slugify>=4.0.0',


Test patch:
diff --git a/tests/test_read_user_dict.py b/tests/test_read_user_dict.py
--- a/tests/test_read_user_dict.py
+++ b/tests/test_read_user_dict.py
@@ -102,6 +102,17 @@ def test_should_call_prompt_with_process_json(mocker):
     )
 
 
+def test_should_not_call_process_json_default_value(mocker, monkeypatch):
+    """Make sure that `process_json` is not called when using default value."""
+    mock_process_json = mocker.patch('cookiecutter.prompt.process_json', autospec=True)
+
+    runner = click.testing.CliRunner()
+    with runner.isolation(input="\n"):
+        read_user_dict('name', {'project_slug': 'pytest-plugin'})
+
+    mock_process_json.assert_not_called()
+
+
 def test_read_user_dict_default_value(mocker):
     """Make sure that `read_user_dict` returns the default value.