Skip to content

Commit

Permalink
Fix importing Literal for Python 3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
leszekhanusz committed Jul 13, 2024
1 parent 3a762ae commit fcd59dc
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion gql/transport/aiohttp_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncio
import json
import logging
import sys
import warnings
from contextlib import suppress
from ssl import SSLContext
Expand All @@ -11,7 +12,6 @@
AsyncGenerator,
Collection,
Dict,
Literal,
Mapping,
Optional,
Tuple,
Expand All @@ -33,6 +33,16 @@
TransportServerError,
)

"""
Load the appropriate instance of the Literal type
Note: we cannot use try: except ImportError because of the following mypy issue:
https://github.com/python/mypy/issues/8520
"""
if sys.version_info[:2] >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal # pragma: no cover

log = logging.getLogger("gql.transport.aiohttp_websockets")

ParsedAnswer = Tuple[str, Optional[ExecutionResult]]
Expand Down

0 comments on commit fcd59dc

Please sign in to comment.