Skip to content

Commit

Permalink
remove some extra code/dependencies that are not required anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
bellini666 committed Dec 21, 2024
1 parent 79db7ef commit f5e224d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 32 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: |
3.8
3.9
3.10
3.11
Expand Down
9 changes: 4 additions & 5 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
Release type: minor

This release drops support for Python 3.8, which has reached EOL on
October 2024. The minimum supported Python version is now 3.9.
This release drops support for Python 3.8, which reached its end-of-life (EOL)
in October 2024. The minimum supported Python version is now 3.9.

It's recommended to upgrade to Python 3.9 or preferably a newer version, as
older versions are no longer supported by the Python Software Foundation itself
and thus may contain security vulnerabilities.
We strongly recommend upgrading to Python 3.9 or a newer version, as older
versions are no longer maintained and may contain security vulnerabilities.
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ python-multipart = {version = ">=0.0.7", optional = true}
sanic = {version = ">=20.12.2", optional = true}
aiohttp = {version = "^3.7.4.post0", optional = true}
fastapi = {version = ">=0.65.2", optional = true}
litestar = {version = ">=2", optional = true, python = ">=3.8"}
litestar = {version = ">=2", optional = true}
channels = {version = ">=3.0.5", optional = true}
astunparse = {version = "^1.6.3", python = "<3.9"}
libcst = {version = ">=0.4.7", optional = true}
rich = {version = ">=12.0.0", optional = true}
pyinstrument = {version = ">=4.0.0", optional = true}
graphlib_backport = {version = "*", python = "<3.9", optional = true}

[tool.poetry.group.dev.dependencies]
asgiref = "^3.2"
Expand Down
24 changes: 3 additions & 21 deletions strawberry/utils/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from collections.abc import AsyncGenerator
from functools import lru_cache
from typing import ( # type: ignore
TYPE_CHECKING,
Annotated,
Any,
ClassVar,
Expand All @@ -22,17 +21,6 @@
)
from typing_extensions import TypeGuard, get_args, get_origin

ast_unparse = getattr(ast, "unparse", None)
# ast.unparse is only available on python 3.9+. For older versions we will
# use `astunparse.unparse`.
# We are also using "not TYPE_CHECKING" here because mypy gives an erorr
# on tests because "astunparse" is missing stubs, but the mypy action says
# that the comment is unused.
if not TYPE_CHECKING and ast_unparse is None:
import astunparse

ast_unparse = astunparse.unparse


@lru_cache
def get_generic_alias(type_: type) -> type:
Expand Down Expand Up @@ -234,8 +222,7 @@ def _ast_replace_union_operation(
if hasattr(ast, "Index") and isinstance(expr.slice, ast.Index):
expr = ast.Subscript(
expr.value,
# The cast is required for mypy on python 3.7 and 3.8
ast.Index(_ast_replace_union_operation(cast(Any, expr.slice).value)), # type: ignore
ast.Index(_ast_replace_union_operation(expr.slice.value)), # type: ignore
ast.Load(),
)
elif isinstance(expr.slice, (ast.BinOp, ast.Tuple)):
Expand Down Expand Up @@ -270,7 +257,6 @@ def _get_namespace_from_ast(
and expr.value.id == "Union"
):
if hasattr(ast, "Index") and isinstance(expr.slice, ast.Index):
# The cast is required for mypy on python 3.7 and 3.8
expr_slice = cast(Any, expr.slice).value
else:
expr_slice = expr.slice
Expand All @@ -288,18 +274,15 @@ def _get_namespace_from_ast(
and isinstance(expr.value, ast.Name)
and expr.value.id == "Annotated"
):
assert ast_unparse

if hasattr(ast, "Index") and isinstance(expr.slice, ast.Index):
# The cast is required for mypy on python 3.7 and 3.8
expr_slice = cast(Any, expr.slice).value
else:
expr_slice = expr.slice

args: list[str] = []
for elt in cast(ast.Tuple, expr_slice).elts:
extra.update(_get_namespace_from_ast(elt, globalns, localns))
args.append(ast_unparse(elt))
args.append(ast.unparse(elt))

# When using forward refs, the whole
# Annotated[SomeType, strawberry.lazy("type.module")] is a forward ref,
Expand Down Expand Up @@ -343,8 +326,7 @@ def eval_type(

globalns.update(_get_namespace_from_ast(ast_obj, globalns, localns))

assert ast_unparse
type_ = ForwardRef(ast_unparse(ast_obj))
type_ = ForwardRef(ast.unparse(ast_obj))

extra: dict[str, Any] = {}

Expand Down

0 comments on commit f5e224d

Please sign in to comment.