strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
3.98k stars 532 forks source link

Make starlite optional #2663

Closed g-as closed 1 year ago

g-as commented 1 year ago

As of 0.168.0, starlite becomes a mandatory dependency, which seems like either an oversight (relative to other integrations) or a misconfiguration.

See the content of https://pypi.org/pypi/strawberry-graphql/json:

        "requires_dist": [
            "graphql-core (>=3.2.0,<3.3.0)",
            "typing_extensions (>=3.7.4,<5.0.0)",
            "python-dateutil (>=2.7.0,<3.0.0)",
            "starlette (>=0.18.0) ; extra == \"asgi\" or extra == \"debug-server\"",
            "click (>=7.0,<9.0) ; extra == \"debug-server\" or extra == \"cli\"",
            "pygments (>=2.3,<3.0) ; extra == \"debug-server\" or extra == \"cli\"",
            "uvicorn (>=0.11.6,<0.22.0) ; extra == \"debug-server\"",
            "Django (>=3.2) ; extra == \"django\"",
            "asgiref (>=3.2,<4.0) ; extra == \"django\" or extra == \"channels\"",
            "flask (>=1.1) ; extra == \"flask\"",
            "opentelemetry-api (<2) ; extra == \"opentelemetry\"",
            "opentelemetry-sdk (<2) ; extra == \"opentelemetry\"",
            "chalice (>=1.22,<2.0) ; extra == \"chalice\"",
            "pydantic (<2) ; extra == \"pydantic\"",
            "python-multipart (>=0.0.5,<0.0.7) ; extra == \"asgi\" or extra == \"debug-server\" or extra == \"fastapi\"",
            "sanic (>=20.12.2) ; extra == \"sanic\"",
            "aiohttp (>=3.7.4.post0,<4.0.0) ; extra == \"aiohttp\"",
            "fastapi (>=0.65.2) ; extra == \"fastapi\"",
            "starlite (>=1.48.0) ; python_version >= \"3.8\" and python_version < \"4.0\"",
            "channels (>=3.0.5) ; extra == \"channels\"",
            "backports.cached-property (>=1.0.2,<2.0.0) ; python_version < \"3.8\"",
            "astunparse (>=1.6.3,<2.0.0) ; python_version < \"3.9\"",
            "libcst (>=0.4.7) ; extra == \"debug\" or extra == \"debug-server\" or extra == \"cli\"",
            "rich (>=12.0.0) ; extra == \"debug\" or extra == \"debug-server\" or extra == \"cli\""
        ],

starlite is not linked to an extra identifier.

See also strawberry in a poetry.lock:

[[package]]
name = "strawberry-graphql"
version = "0.168.0"
description = "A library for creating GraphQL APIs"
category = "main"
optional = false
python-versions = ">=3.7,<4.0"
files = [
    {file = "strawberry_graphql-0.168.0-py3-none-any.whl", hash = "sha256:6beaaad859edda74ffb63faafb9bc5b0ae88b4a7cf3d918bb858feb21b4428fa"},
    {file = "strawberry_graphql-0.168.0.tar.gz", hash = "sha256:6a97b6dcc87fdd4b68eed6503fab457979d2fa030f4c05ab6ca44d069b338b9c"},
]

[package.dependencies]
graphql-core = ">=3.2.0,<3.3.0"
libcst = {version = ">=0.4.7", optional = true, markers = "extra == \"debug\" or extra == \"debug-server\" or extra == \"cli\""}
python-dateutil = ">=2.7.0,<3.0.0"
rich = {version = ">=12.0.0", optional = true, markers = "extra == \"debug\" or extra == \"debug-server\" or extra == \"cli\""}
starlite = {version = ">=1.48.0", markers = "python_version >= \"3.8\" and python_version < \"4.0\""}
typing_extensions = ">=3.7.4,<5.0.0"

[package.extras]
aiohttp = ["aiohttp (>=3.7.4.post0,<4.0.0)"]
asgi = ["python-multipart (>=0.0.5,<0.0.7)", "starlette (>=0.18.0)"]
chalice = ["chalice (>=1.22,<2.0)"]
channels = ["asgiref (>=3.2,<4.0)", "channels (>=3.0.5)"]
cli = ["click (>=7.0,<9.0)", "libcst (>=0.4.7)", "pygments (>=2.3,<3.0)", "rich (>=12.0.0)"]
debug = ["libcst (>=0.4.7)", "rich (>=12.0.0)"]
debug-server = ["click (>=7.0,<9.0)", "libcst (>=0.4.7)", "pygments (>=2.3,<3.0)", "python-multipart (>=0.0.5,<0.0.7)", "rich (>=12.0.0)", "starlette (>=0.18.0)", "uvicorn (>=0.11.6,<0.22.0)"]
django = ["Django (>=3.2)", "asgiref (>=3.2,<4.0)"]
fastapi = ["fastapi (>=0.65.2)", "python-multipart (>=0.0.5,<0.0.7)"]
flask = ["flask (>=1.1)"]
opentelemetry = ["opentelemetry-api (<2)", "opentelemetry-sdk (<2)"]
pydantic = ["pydantic (<2)"]
sanic = ["sanic (>=20.12.2)"]

Also, starlite package already knows its compatibility with python, having it specified in strawberry feels redundant (^3.8). I'm only saying this because we already had this conversation with django's python versions, and ended up only specifying a lower bound (https://github.com/strawberry-graphql/strawberry/pull/1687).

patrick91 commented 1 year ago

ah interesting, it looks like if you don't use an extra it gets added to the dependency anyway, event if it is optional: https://github.com/strawberry-graphql/strawberry/blob/main/pyproject.toml#L58

I'll make the updated now! Thanks for the check! I'll also remove the python version specifier 😊

patrick91 commented 1 year ago

if I remove the version specifier I get this:

poetry lock
Updating dependencies
Resolving dependencies... (9.1s)

The current project's Python requirement (>=3.7,<4.0) is not compatible with some of the required packages Python requirement:
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8
  - starlite requires Python >=3.8,<4.0, so it will not be satisfied for Python >=3.7,<3.8