Repository: pypa/pipenv

Issue:
pipenv lock doesn't work after latest update
### Issue description

When trying to lock the dependencies for my project, it fails with this error
```
pipenv.exceptions.DependencyConflict: ERROR: Cannot resolve conflicting version django<3.0,>=2.2.9 while django==3.1.3 is locked.
```
even though Django 3.1 is not used in the project

### Expected result

`pipenv lock` to succeed

### Actual result

<details><summary>$ pipenv lock --verbose</summary>

```
Locking [dev-packages] dependencies...
Building requirements...
Resolving dependencies...
⠋ Locking...
                          ROUND 1                           
✘ Locking Failed! 
Current constraints:
  django-debug-toolbar (from -r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))

Finding the best candidates:
  found candidate django-debug-toolbar==3.1.1 (constraint was <any>)

Finding secondary dependencies:
  django-debug-toolbar==3.1.1 requires django>=2.2, sqlparse>=0.2.0

New dependencies found in this round:
  adding ['django', '>=2.2', '[]']
  adding ['sqlparse', '>=0.2.0', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  django>=2.2 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  django-debug-toolbar (from -r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  sqlparse>=0.2.0 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))

Finding the best candidates:
  found candidate django==3.1.3 (constraint was >=2.2)
  found candidate django-debug-toolbar==3.1.1 (constraint was <any>)
  found candidate sqlparse==0.4.1 (constraint was >=0.2.0)

Finding secondary dependencies:
  django-debug-toolbar==3.1.1 requires django>=2.2, sqlparse>=0.2.0
  django==3.1.3             requires asgiref<4,>=3.2.10, pytz, sqlparse>=0.2.2
  sqlparse==0.4.1           requires -

New dependencies found in this round:
  adding ['asgiref', '<4,>=3.2.10', '[]']
  adding ['pytz', '', '[]']
  adding ['sqlparse', '>=0.2.0,>=0.2.2', '[]']
Removed dependencies in this round:
  removing ['sqlparse', '>=0.2.0', '[]']
------------------------------------------------------------
Result of round 2: not stable

                          ROUND 3                           
Current constraints:
  asgiref<4,>=3.2.10 (from django==3.1.3->django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  django>=2.2 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  django-debug-toolbar (from -r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  pytz (from django==3.1.3->django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  sqlparse>=0.2.0,>=0.2.2 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))

Finding the best candidates:
  found candidate asgiref==3.3.1 (constraint was >=3.2.10,<4)
  found candidate django==3.1.3 (constraint was >=2.2)
  found candidate django-debug-toolbar==3.1.1 (constraint was <any>)
  found candidate pytz==2020.4 (constraint was <any>)
  found candidate sqlparse==0.4.1 (constraint was >=0.2.0,>=0.2.2)

Finding secondary dependencies:
  asgiref==3.3.1            requires -
  django==3.1.3             requires asgiref<4,>=3.2.10, pytz, sqlparse>=0.2.2
  django-debug-toolbar==3.1.1 requires django>=2.2, sqlparse>=0.2.0
  sqlparse==0.4.1           requires -
  pytz==2020.4              requires -
------------------------------------------------------------
Result of round 3: stable, done

Generating hashes:
  asgiref
  django
  django-debug-toolbar
  sqlparse
  pytz
Tried constraint: <InstallRequirement object: django<3.0,>=2.2.9 editable=False>
Traceback (most recent call last):
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 763, in <module>
    main()
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 759, in main
    parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project)
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 596, in clean_results
    entry_dict = translate_markers(entry.get_cleaned_dict(keep_outdated=False))
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 239, in get_cleaned_dict
    self.validate_constraints()
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 536, in validate_constraints
    raise DependencyConflict(msg)
pipenv.exceptions.DependencyConflict: ERROR: Cannot resolve conflicting version django<3.0,>=2.2.9 while django==3.1.3 is locked.
ROUND 1                           
Current constraints:
  django-debug-toolbar (from -r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))

Finding the best candidates:
  found candidate django-debug-toolbar==3.1.1 (constraint was <any>)

Finding secondary dependencies:
  django-debug-toolbar==3.1.1 requires django>=2.2, sqlparse>=0.2.0

New dependencies found in this round:
  adding ['django', '>=2.2', '[]']
  adding ['sqlparse', '>=0.2.0', '[]']
Removed dependencies in this round:
------------------------------------------------------------
Result of round 1: not stable

                          ROUND 2                           
Current constraints:
  django>=2.2 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  django-debug-toolbar (from -r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  sqlparse>=0.2.0 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))

Finding the best candidates:
  found candidate django==3.1.3 (constraint was >=2.2)
  found candidate django-debug-toolbar==3.1.1 (constraint was <any>)
  found candidate sqlparse==0.4.1 (constraint was >=0.2.0)

Finding secondary dependencies:
  django-debug-toolbar==3.1.1 requires django>=2.2, sqlparse>=0.2.0
  django==3.1.3             requires asgiref<4,>=3.2.10, pytz, sqlparse>=0.2.2
  sqlparse==0.4.1           requires -

New dependencies found in this round:
  adding ['asgiref', '<4,>=3.2.10', '[]']
  adding ['pytz', '', '[]']
  adding ['sqlparse', '>=0.2.0,>=0.2.2', '[]']
Removed dependencies in this round:
  removing ['sqlparse', '>=0.2.0', '[]']
------------------------------------------------------------
Result of round 2: not stable

                          ROUND 3                           
Current constraints:
  asgiref<4,>=3.2.10 (from django==3.1.3->django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  django>=2.2 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  django-debug-toolbar (from -r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  pytz (from django==3.1.3->django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))
  sqlparse>=0.2.0,>=0.2.2 (from django-debug-toolbar==3.1.1->-r /tmp/pipenv_gy3sdfkrequirements/pipenv-4p6znxo8-constraints.txt (line 2))

Finding the best candidates:
  found candidate asgiref==3.3.1 (constraint was >=3.2.10,<4)
  found candidate django==3.1.3 (constraint was >=2.2)
  found candidate django-debug-toolbar==3.1.1 (constraint was <any>)
  found candidate pytz==2020.4 (constraint was <any>)
  found candidate sqlparse==0.4.1 (constraint was >=0.2.0,>=0.2.2)

Finding secondary dependencies:
  asgiref==3.3.1            requires -
  django==3.1.3             requires asgiref<4,>=3.2.10, pytz, sqlparse>=0.2.2
  django-debug-toolbar==3.1.1 requires django>=2.2, sqlparse>=0.2.0
  sqlparse==0.4.1           requires -
  pytz==2020.4              requires -
------------------------------------------------------------
Result of round 3: stable, done

Generating hashes:
  asgiref
  django
  django-debug-toolbar
  sqlparse
  pytz
Tried constraint: <InstallRequirement object: django<3.0,>=2.2.9 editable=False>
Traceback (most recent call last):
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 763, in <module>
    main()
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 759, in main
    parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 741, in _main
    resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 714, in resolve_packages
    results = clean_results(results, resolver, project)
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 596, in clean_results
    entry_dict = translate_markers(entry.get_cleaned_dict(keep_outdated=False))
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 239, in get_cleaned_dict
    self.validate_constraints()
  File "/home/kususer/.local/lib/python3.6/site-packages/pipenv/resolver.py", line 536, in validate_constraints
    raise DependencyConflict(msg)
pipenv.exceptions.DependencyConflict: ERROR: Cannot resolve conflicting version django<3.0,>=2.2.9 while django==3.1.3 is locked.
```

</details>

### Steps to replicate

```
pipenv install 'Django>=2.2.9,<3.0'
pipenv install --dev django-debug-toolbar
```

-------------------------------------------------------------------------------

<details><summary>$ pipenv --support</summary>

Pipenv version: `'2020.11.4'`

Pipenv location: `'/home/kususer/.local/lib/python3.6/site-packages/pipenv'`

Python location: `'/usr/bin/python3'`

Python installations found:

  - `3.6.8`: `/usr/bin/python3`
  - `3.6.8`: `/usr/bin/python3.6`
  - `3.6.8`: `/usr/bin/python3.6m`
  - `3.6.8`: `/bin/python3`
  - `3.6.8`: `/bin/python3.6`
  - `3.6.8`: `/bin/python3.6m`
  - `2.7.5`: `/usr/bin/python2`
  - `2.7.5`: `/usr/bin/python2.7`
  - `2.7.5`: `/bin/python2`
  - `2.7.5`: `/bin/python2.7`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '3.6.8',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '3.10.0-1160.2.2.el7.x86_64',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Sat Oct 17 05:06:47 UTC 2020',
 'python_full_version': '3.6.8',
 'python_version': '3.6',
 'sys_platform': 'linux'}
```

System environment variables:

  - `COLORTERM`
  - `DBUS_SESSION_BUS_ADDRESS`
  - `DESKTOP_SESSION`
  - `DISPLAY`
  - `GDMSESSION`
  - `GDM_LANG`
  - `GJS_DEBUG_OUTPUT`
  - `GJS_DEBUG_TOPICS`
  - `GNOME_DESKTOP_SESSION_ID`
  - `GNOME_SHELL_SESSION_MODE`
  - `GNOME_TERMINAL_SCREEN`
  - `GNOME_TERMINAL_SERVICE`
  - `HOME`
  - `IMSETTINGS_INTEGRATE_DESKTOP`
  - `IMSETTINGS_MODULE`
  - `LANG`
  - `LESS`
  - `LOGNAME`
  - `LS_COLORS`
  - `PATH`
  - `PWD`
  - `QT_IM_MODULE`
  - `RPM_PACKAGER`
  - `SESSION_MANAGER`
  - `SHELL`
  - `SHLVL`
  - `SSH_AGENT_PID`
  - `SSH_AUTH_SOCK`
  - `TERM`
  - `USER`
  - `USERNAME`
  - `VTE_VERSION`
  - `WINDOWPATH`
  - `XAUTHORITY`
  - `XDG_CURRENT_DESKTOP`
  - `XDG_DATA_DIRS`
  - `XDG_MENU_PREFIX`
  - `XDG_RUNTIME_DIR`
  - `XDG_SEAT`
  - `XDG_SESSION_DESKTOP`
  - `XDG_SESSION_ID`
  - `XDG_SESSION_TYPE`
  - `XDG_VTNR`
  - `XMODIFIERS`
  - `fish_user_paths`
  - `PIP_DISABLE_PIP_VERSION_CHECK`
  - `PYTHONDONTWRITEBYTECODE`
  - `PIP_SHIMS_BASE_MODULE`
  - `PIP_PYTHON_PATH`
  - `PYTHONFINDER_IGNORE_UNSUPPORTED`

Pipenv–specific environment variables:


Debug–specific environment variables:

  - `PATH`: `/home/kususer/bin/:/home/kususer/.local/bin/:/home/kususer/.poetry/bin/:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin`
  - `SHELL`: `/usr/bin/fish`
  - `LANG`: `en_US.UTF-8`
  - `PWD`: `/home/kususer/Documents/pl`


---------------------------

Contents of `Pipfile` ('/home/kususer/Documents/pl/Pipfile'):

```toml
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = ">=2.2.9,<3.0"

[dev-packages]
django-debug-toolbar = "*"

[requires]
python_version = "3.6"

```


Contents of `Pipfile.lock` ('/home/kususer/Documents/pl/Pipfile.lock'):

```json
{
    "_meta": {
        "hash": {
            "sha256": "380611a92b6137f3ca308e9814f3889804511816acbb9b9411e8b3f3d7d73620"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "3.6"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {
        "django": {
            "hashes": [
                "sha256:558cb27930defd9a6042133258caf797b2d1dee233959f537e3dc475cb49bd7c",
                "sha256:cf5370a4d7765a9dd6d42a7b96b53c74f9446cd38209211304b210fe0404b861"
            ],
            "index": "pypi",
            "version": "==2.2.17"
        },
        "pytz": {
            "hashes": [
                "sha256:3e6b7dd2d1e0a59084bcee14a17af60c5c562cdc16d828e8eba2e683d3a7e268",
                "sha256:5c55e189b682d420be27c6995ba6edce0c0a77dd67bfbe2ae6607134d5851ffd"
            ],
            "version": "==2020.4"
        },
        "sqlparse": {
            "hashes": [
                "sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0",
                "sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8"
            ],
            "markers": "python_version >= '3.5'",
            "version": "==0.4.1"
        }
    },
    "develop": {}
}

```
</details>



Discussion:

Resolving patch:
diff --git a/pipenv/resolver.py b/pipenv/resolver.py
--- a/pipenv/resolver.py
+++ b/pipenv/resolver.py
@@ -670,7 +670,7 @@ def parse_packages(packages, pre, clear, system, requirements_dir=None):
         print(json.dumps([]))
 
 
-def resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages):
+def resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev):
     from pipenv.utils import create_mirror_source, resolve_deps, replace_pypi_sources
     pypi_mirror_source = (
         create_mirror_source(os.environ["PIPENV_PYPI_MIRROR"])
@@ -709,9 +709,9 @@ def resolve(packages, pre, project, sources, clear, system, requirements_dir=Non
         requirements_dir=requirements_dir,
     )
     if keep_outdated:
-        results = clean_outdated(results, resolver, project)
+        results = clean_outdated(results, resolver, project, dev)
     else:
-        results = clean_results(results, resolver, project)
+        results = clean_results(results, resolver, project, dev)
     if write:
         with open(write, "w") as fh:
             if not results:
@@ -726,7 +726,7 @@ def resolve(packages, pre, project, sources, clear, system, requirements_dir=Non
             print(json.dumps([]))
 
 
-def _main(pre, clear, verbose, system, write, requirements_dir, packages, parse_only=False):
+def _main(pre, clear, verbose, system, write, requirements_dir, packages, parse_only=False, dev=False):
     os.environ["PIPENV_REQUESTED_PYTHON_VERSION"] = ".".join([str(s) for s in sys.version_info[:3]])
     os.environ["PIP_PYTHON_PATH"] = str(sys.executable)
     if parse_only:
@@ -738,7 +738,7 @@ def _main(pre, clear, verbose, system, write, requirements_dir, packages, parse_
             requirements_dir=requirements_dir,
         )
     else:
-        resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages)
+        resolve_packages(pre, clear, verbose, system, write, requirements_dir, packages, dev)
 
 
 def main():
@@ -756,7 +756,8 @@ def main():
     os.environ["PYTHONUNBUFFERED"] = str("1")
     parsed = handle_parsed_args(parsed)
     _main(parsed.pre, parsed.clear, parsed.verbose, parsed.system, parsed.write,
-          parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only)
+          parsed.requirements_dir, parsed.packages, parse_only=parsed.parse_only,
+          dev=parsed.dev)
 
 
 if __name__ == "__main__":


Test patch:
diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py
--- a/tests/integration/test_lock.py
+++ b/tests/integration/test_lock.py
@@ -775,3 +775,15 @@ def test_lock_package_with_wildcard_version(PipenvInstance):
         assert "six" in p.lockfile["default"]
         assert "version" in p.lockfile["default"]["six"]
         assert p.lockfile["default"]["six"]["version"] == "==1.11.0"
+
+
+@pytest.mark.lock
+@pytest.mark.install
+def test_default_lock_overwrite_dev_lock(PipenvInstance):
+    with PipenvInstance(chdir=True) as p:
+        c = p.pipenv("install 'click==6.7'")
+        assert c.ok
+        c = p.pipenv("install -d flask")
+        assert c.ok
+        assert p.lockfile["default"]["click"]["version"] == "==6.7"
+        assert p.lockfile["develop"]["click"]["version"] == "==6.7"