Repository: python-poetry/poetry

Issue:
Maximum recursion depth exceeded for `requests[security]` introduced in 1.0.0b4
<!--
  Hi there! Thank you for discovering and submitting an issue.

  Before you submit this; let's make sure of a few things.
  Please make sure the following boxes are ticked if they are correct.
  If not, please try and fulfill these first.
-->

<!-- Checked checkbox should look like this: [x] -->
- [x ] I am on the [latest](https://github.com/sdispater/poetry/releases/latest) Poetry version.
- [x ] I have searched the [issues](https://github.com/sdispater/poetry/issues) of this repo and believe that this is not a duplicate.
- [x ] If an exception occurs when executing a command, I executed it again in debug mode (`-vvv` option).

<!--
  Once those are done, if you're able to fill in the following list with your information,
  it'd be very helpful to whoever handles the issue.
-->

- **OS version and name**: OSX 10.14.5
- **Poetry version**: 1.0.0b4
- **Link of a [Gist](https://gist.github.com/) with the contents of your pyproject.toml file**: https://gist.github.com/tonysyu/82b3fc28b01e0fec6e53cece29adc7db

## Issue

While testing out the extras export fix for https://github.com/sdispater/poetry/issues/1313, I tried setting up a new project (with the `pyproject.toml` linked above) and ran into the following issue:
```
$ poetry --version
Poetry version 1.0.0b4

$ poetry add -v3 requests[security]
The currently activated Python version 2.7.13 is not supported by the project (^3.6).
Trying to find and use a compatible version.
Using python3 (3.6.5)
Using version ^2.22.0 for requests

Updating dependencies
Resolving dependencies... (13.7s)
Resolving dependencies... (13.8s)
[RuntimeError]
maximum recursion depth exceeded while calling a Python object
```
- Running the same command on 1.0.0b3 works as expected
- Running `poetry add requests` (without the extras) works as expected


Discussion:
I know where the issue is coming from and it has been introduced in https://github.com/sdispater/poetry/pull/1555.

I'll try to make a fix as soon as possible.

Sorry for the regression!
I don’t know if this is related, but it is happening on two projects of mine:

```bash
poetry update
Updating dependencies
Resolving dependencies... (4.2s)

[TooManyRedirects]
Exceeded 30 redirects.
```
Ok, [fixed cleaning the cache](https://github.com/sdispater/poetry/issues/1445). Sorry for using your ticket for my issue.

Resolving patch:
diff --git a/poetry/puzzle/provider.py b/poetry/puzzle/provider.py
--- a/poetry/puzzle/provider.py
+++ b/poetry/puzzle/provider.py
@@ -604,7 +604,7 @@ def complete_package(
                 new_markers = []
                 for dep in _deps:
                     marker = dep.marker.without_extras()
-                    if marker.is_empty():
+                    if marker.is_any():
                         # No marker or only extras
                         continue
 


Test patch:
diff --git a/tests/puzzle/test_solver.py b/tests/puzzle/test_solver.py
--- a/tests/puzzle/test_solver.py
+++ b/tests/puzzle/test_solver.py
@@ -1831,3 +1831,28 @@ def test_solver_does_not_raise_conflict_for_conditional_dev_dependencies(
             {"job": "install", "package": package_a200},
         ],
     )
+
+
+def test_solver_does_not_loop_indefinitely_on_duplicate_constraints_with_extras(
+    solver, repo, package
+):
+    package.python_versions = "~2.7 || ^3.5"
+    package.add_dependency("requests", {"version": "^2.22.0", "extras": ["security"]})
+
+    requests = get_package("requests", "2.22.0")
+    requests.add_dependency("idna", ">=2.5,<2.9")
+    requests.add_dependency(
+        "idna", {"version": ">=2.0.0", "markers": "extra == 'security'"}
+    )
+    requests.extras["security"] = [get_dependency("idna", ">=2.0.0")]
+    idna = get_package("idna", "2.8")
+
+    repo.add_package(requests)
+    repo.add_package(idna)
+
+    ops = solver.solve()
+
+    check_solver_result(
+        ops,
+        [{"job": "install", "package": idna}, {"job": "install", "package": requests}],
+    )