From 9444c308aeb5b7bb35a8d4357de9a0dbda5b128f Mon Sep 17 00:00:00 2001 From: Thiago Bellini Ribeiro Date: Tue, 8 Aug 2023 18:52:46 -0300 Subject: [PATCH] refactor: bump ruff's minimum python version to 3.8 and remove remaining python 3.7 code (#2995) Co-authored-by: Patrick Arminio --- RELEASE.md | 5 +++ docs/types/schema.md | 5 +-- poetry.lock | 2 +- pyproject.toml | 3 +- strawberry/channels/handlers/http_handler.py | 2 +- strawberry/directive.py | 2 +- strawberry/exceptions/__init__.py | 3 +- strawberry/exceptions/duplicated_type_name.py | 3 +- strawberry/exceptions/exception.py | 2 +- strawberry/exceptions/handler.py | 11 ++---- .../exceptions/invalid_argument_type.py | 2 +- strawberry/exceptions/invalid_union_type.py | 2 +- .../missing_arguments_annotations.py | 3 +- .../exceptions/missing_field_annotation.py | 3 +- .../exceptions/missing_return_annotation.py | 3 +- .../exceptions/not_a_strawberry_enum.py | 3 +- .../exceptions/object_is_not_a_class.py | 3 +- .../exceptions/object_is_not_an_enum.py | 3 +- .../exceptions/private_strawberry_field.py | 3 +- .../exceptions/scalar_already_registered.py | 2 +- .../exceptions/unresolved_field_type.py | 2 +- strawberry/exceptions/utils/source_finder.py | 3 +- strawberry/extensions/field_extension.py | 3 +- strawberry/extensions/tracing/datadog.py | 2 +- strawberry/extensions/tracing/sentry.py | 2 +- strawberry/federation/schema.py | 3 +- strawberry/field.py | 2 +- strawberry/relay/exceptions.py | 2 +- strawberry/schema/base.py | 2 +- strawberry/schema/schema.py | 4 +- strawberry/types/fields/resolver.py | 2 +- strawberry/types/info.py | 3 +- strawberry/utils/cached_property.py | 38 ------------------- strawberry/utils/logging.py | 6 +-- strawberry/utils/typing.py | 2 +- .../test_threading_exception_handler.py | 17 --------- tests/starlite/test_context.py | 8 ---- tests/starlite/test_response_headers.py | 9 ----- tests/starlite/test_response_status.py | 9 ----- tests/starlite/test_websockets.py | 7 ---- tests/websockets/test_graphql_transport_ws.py | 5 --- 41 files changed, 42 insertions(+), 154 deletions(-) create mode 100644 RELEASE.md delete mode 100644 strawberry/utils/cached_property.py diff --git a/RELEASE.md b/RELEASE.md new file mode 100644 index 0000000000..7f0e3c881b --- /dev/null +++ b/RELEASE.md @@ -0,0 +1,5 @@ +Release type: minor + +This release updates Strawberry's codebase to use new features in Python 3.8. +It also removes `backports.cached-property` from our dependencies, as we can +now rely on the standard library's `functools.cached_property`. diff --git a/docs/types/schema.md b/docs/types/schema.md index 625cf43797..9c919aa7f6 100644 --- a/docs/types/schema.md +++ b/docs/types/schema.md @@ -229,10 +229,7 @@ class StrawberryLogger: if logger_kwargs.get("stack_info") is None: logger_kwargs["stack_info"] = True - # stacklevel was added in version 3.8 - # https://docs.python.org/3/library/logging.html#logging.Logger.debug - if sys.version_info >= (3, 8): - logger_kwargs["stacklevel"] = 3 + logger_kwargs["stacklevel"] = 3 cls.logger.error(error, exc_info=error.original_error, **logger_kwargs) ``` diff --git a/poetry.lock b/poetry.lock index 20b386c924..f4ec0bc7d1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -3866,4 +3866,4 @@ starlite = ["starlite"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "496c086c3b1b253201352e45a09e5167756a57e26748ebdd506c5a82faae1fae" +content-hash = "b53f0b2fb5069cec2f4a9a7d79d3f039cd1d693db63029f67ad06ef0a20b8b59" diff --git a/pyproject.toml b/pyproject.toml index c46124a6b5..6d543d1fbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,6 @@ aiohttp = {version = "^3.7.4.post0", optional = true} fastapi = {version = ">=0.65.2", optional = true} starlite = {version = ">=1.48.0", optional = true, python = ">=3.8"} channels = {version = ">=3.0.5", optional = true} -"backports.cached-property" = {version = "^1.0.2", python = "<3.8"} astunparse = {version = "^1.6.3", python = "<3.9"} libcst = {version = ">=0.4.7", optional = true} rich = {version = ">=12.0.0", optional = true} @@ -191,7 +190,7 @@ stubPath = "" [tool.ruff] line-length = 88 select = ["ALL"] -target-version = "py37" +target-version = "py38" ignore = [ # https://github.com/astral-sh/ruff/pull/4427 # equivalent to keep-runtime-typing diff --git a/strawberry/channels/handlers/http_handler.py b/strawberry/channels/handlers/http_handler.py index b0b7477aa3..72c2406418 100644 --- a/strawberry/channels/handlers/http_handler.py +++ b/strawberry/channels/handlers/http_handler.py @@ -6,6 +6,7 @@ import dataclasses import json +from functools import cached_property from io import BytesIO from typing import TYPE_CHECKING, Any, Dict, Mapping, Optional, Union from urllib.parse import parse_qs @@ -23,7 +24,6 @@ from strawberry.http.types import FormData from strawberry.http.typevars import Context, RootValue from strawberry.unset import UNSET -from strawberry.utils.cached_property import cached_property from strawberry.utils.graphiql import get_graphiql_html from .base import ChannelsConsumer diff --git a/strawberry/directive.py b/strawberry/directive.py index 3b8f34a46c..5fb2c734ff 100644 --- a/strawberry/directive.py +++ b/strawberry/directive.py @@ -1,6 +1,7 @@ from __future__ import annotations import dataclasses +from functools import cached_property from typing import TYPE_CHECKING, Any, Callable, Generic, List, Optional, TypeVar from typing_extensions import Annotated @@ -13,7 +14,6 @@ StrawberryResolver, ) from strawberry.unset import UNSET -from strawberry.utils.cached_property import cached_property if TYPE_CHECKING: import inspect diff --git a/strawberry/exceptions/__init__.py b/strawberry/exceptions/__init__.py index 7246b81da4..1dfb857d0f 100644 --- a/strawberry/exceptions/__init__.py +++ b/strawberry/exceptions/__init__.py @@ -1,11 +1,10 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional, Set, Union from graphql import GraphQLError -from strawberry.utils.cached_property import cached_property - from .duplicated_type_name import DuplicatedTypeName from .exception import StrawberryException, UnableToFindExceptionSource from .handler import setup_exception_handler diff --git a/strawberry/exceptions/duplicated_type_name.py b/strawberry/exceptions/duplicated_type_name.py index 34975e89fe..49e3a335df 100644 --- a/strawberry/exceptions/duplicated_type_name.py +++ b/strawberry/exceptions/duplicated_type_name.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional, Type -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/exception.py b/strawberry/exceptions/exception.py index 87e1325d21..f75ce488ef 100644 --- a/strawberry/exceptions/exception.py +++ b/strawberry/exceptions/exception.py @@ -1,9 +1,9 @@ from __future__ import annotations from abc import ABC, abstractmethod +from functools import cached_property from typing import TYPE_CHECKING, Optional -from strawberry.utils.cached_property import cached_property from strawberry.utils.str_converters import to_kebab_case if TYPE_CHECKING: diff --git a/strawberry/exceptions/handler.py b/strawberry/exceptions/handler.py index c0b94fbcd6..ba2a6e4b00 100644 --- a/strawberry/exceptions/handler.py +++ b/strawberry/exceptions/handler.py @@ -6,10 +6,7 @@ from .exception import StrawberryException, UnableToFindExceptionSource -if sys.version_info >= (3, 8): - original_threading_exception_hook = threading.excepthook -else: - original_threading_exception_hook = None +original_threading_exception_hook = threading.excepthook ExceptionHandler = Callable[ @@ -83,13 +80,11 @@ def strawberry_threading_exception_handler( def reset_exception_handler() -> None: sys.excepthook = sys.__excepthook__ - if sys.version_info >= (3, 8): - threading.excepthook = original_threading_exception_hook + threading.excepthook = original_threading_exception_hook def setup_exception_handler() -> None: if should_use_rich_exceptions(): sys.excepthook = strawberry_exception_handler - if sys.version_info >= (3, 8): - threading.excepthook = strawberry_threading_exception_handler + threading.excepthook = strawberry_threading_exception_handler diff --git a/strawberry/exceptions/invalid_argument_type.py b/strawberry/exceptions/invalid_argument_type.py index 32345edc49..7b00cdccba 100644 --- a/strawberry/exceptions/invalid_argument_type.py +++ b/strawberry/exceptions/invalid_argument_type.py @@ -1,9 +1,9 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional from strawberry.type import get_object_definition -from strawberry.utils.cached_property import cached_property from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/invalid_union_type.py b/strawberry/exceptions/invalid_union_type.py index ede4ee82d5..cd54b8dfae 100644 --- a/strawberry/exceptions/invalid_union_type.py +++ b/strawberry/exceptions/invalid_union_type.py @@ -1,11 +1,11 @@ from __future__ import annotations +from functools import cached_property from inspect import getframeinfo, stack from pathlib import Path from typing import TYPE_CHECKING, Optional, Type from strawberry.exceptions.utils.source_finder import SourceFinder -from strawberry.utils.cached_property import cached_property from .exception import StrawberryException diff --git a/strawberry/exceptions/missing_arguments_annotations.py b/strawberry/exceptions/missing_arguments_annotations.py index ff185adf34..2947f9e6ac 100644 --- a/strawberry/exceptions/missing_arguments_annotations.py +++ b/strawberry/exceptions/missing_arguments_annotations.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, List, Optional -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/missing_field_annotation.py b/strawberry/exceptions/missing_field_annotation.py index 807b5d7ca0..ad279cf325 100644 --- a/strawberry/exceptions/missing_field_annotation.py +++ b/strawberry/exceptions/missing_field_annotation.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional, Type -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/missing_return_annotation.py b/strawberry/exceptions/missing_return_annotation.py index 5dd03f6168..4969fe8cdf 100644 --- a/strawberry/exceptions/missing_return_annotation.py +++ b/strawberry/exceptions/missing_return_annotation.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/not_a_strawberry_enum.py b/strawberry/exceptions/not_a_strawberry_enum.py index c4b8646602..5696fc9920 100644 --- a/strawberry/exceptions/not_a_strawberry_enum.py +++ b/strawberry/exceptions/not_a_strawberry_enum.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/object_is_not_a_class.py b/strawberry/exceptions/object_is_not_a_class.py index 03116576ae..4419f15a4d 100644 --- a/strawberry/exceptions/object_is_not_a_class.py +++ b/strawberry/exceptions/object_is_not_a_class.py @@ -1,10 +1,9 @@ from __future__ import annotations from enum import Enum +from functools import cached_property from typing import TYPE_CHECKING, Optional -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/object_is_not_an_enum.py b/strawberry/exceptions/object_is_not_an_enum.py index 774ef8a872..1d209cbc64 100644 --- a/strawberry/exceptions/object_is_not_an_enum.py +++ b/strawberry/exceptions/object_is_not_an_enum.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional, Type -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/private_strawberry_field.py b/strawberry/exceptions/private_strawberry_field.py index 54fe4ba8ee..0c09b9c18d 100644 --- a/strawberry/exceptions/private_strawberry_field.py +++ b/strawberry/exceptions/private_strawberry_field.py @@ -1,9 +1,8 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional, Type -from strawberry.utils.cached_property import cached_property - from .exception import StrawberryException from .utils.source_finder import SourceFinder diff --git a/strawberry/exceptions/scalar_already_registered.py b/strawberry/exceptions/scalar_already_registered.py index 59a35b905b..ae24c9b0c0 100644 --- a/strawberry/exceptions/scalar_already_registered.py +++ b/strawberry/exceptions/scalar_already_registered.py @@ -1,10 +1,10 @@ from __future__ import annotations +from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, Optional from strawberry.exceptions.utils.source_finder import SourceFinder -from strawberry.utils.cached_property import cached_property from .exception import StrawberryException diff --git a/strawberry/exceptions/unresolved_field_type.py b/strawberry/exceptions/unresolved_field_type.py index 208e71a37f..9c0406ac2d 100644 --- a/strawberry/exceptions/unresolved_field_type.py +++ b/strawberry/exceptions/unresolved_field_type.py @@ -1,9 +1,9 @@ from __future__ import annotations +from functools import cached_property from typing import TYPE_CHECKING, Optional from strawberry.exceptions.utils.source_finder import SourceFinder -from strawberry.utils.cached_property import cached_property from .exception import StrawberryException diff --git a/strawberry/exceptions/utils/source_finder.py b/strawberry/exceptions/utils/source_finder.py index f0a96047aa..2a3d212be6 100644 --- a/strawberry/exceptions/utils/source_finder.py +++ b/strawberry/exceptions/utils/source_finder.py @@ -4,11 +4,10 @@ import importlib.util import sys from dataclasses import dataclass +from functools import cached_property from pathlib import Path from typing import TYPE_CHECKING, Any, Callable, Optional, Sequence, Type, cast -from strawberry.utils.cached_property import cached_property - from ..exception_source import ExceptionSource if TYPE_CHECKING: diff --git a/strawberry/extensions/field_extension.py b/strawberry/extensions/field_extension.py index b9156754ca..470533548f 100644 --- a/strawberry/extensions/field_extension.py +++ b/strawberry/extensions/field_extension.py @@ -1,10 +1,9 @@ from __future__ import annotations import itertools +from functools import cached_property from typing import TYPE_CHECKING, Any, Awaitable, Callable, Union -from strawberry.utils.cached_property import cached_property - if TYPE_CHECKING: from strawberry.field import StrawberryField from strawberry.types import Info diff --git a/strawberry/extensions/tracing/datadog.py b/strawberry/extensions/tracing/datadog.py index 11bb71b3da..b026a007fd 100644 --- a/strawberry/extensions/tracing/datadog.py +++ b/strawberry/extensions/tracing/datadog.py @@ -1,6 +1,7 @@ from __future__ import annotations import hashlib +from functools import cached_property from inspect import isawaitable from typing import TYPE_CHECKING, Any, Callable, Generator, Iterator, Optional @@ -8,7 +9,6 @@ from strawberry.extensions import LifecycleStep, SchemaExtension from strawberry.extensions.tracing.utils import should_skip_tracing -from strawberry.utils.cached_property import cached_property if TYPE_CHECKING: from graphql import GraphQLResolveInfo diff --git a/strawberry/extensions/tracing/sentry.py b/strawberry/extensions/tracing/sentry.py index 0f026c589d..ebcb0db3c3 100644 --- a/strawberry/extensions/tracing/sentry.py +++ b/strawberry/extensions/tracing/sentry.py @@ -1,6 +1,7 @@ from __future__ import annotations import hashlib +from functools import cached_property from inspect import isawaitable from typing import TYPE_CHECKING, Any, Callable, Generator, Optional @@ -8,7 +9,6 @@ from strawberry.extensions import SchemaExtension from strawberry.extensions.tracing.utils import should_skip_tracing -from strawberry.utils.cached_property import cached_property if TYPE_CHECKING: from graphql import GraphQLResolveInfo diff --git a/strawberry/federation/schema.py b/strawberry/federation/schema.py index 0b6966335a..c7b10e4e2a 100644 --- a/strawberry/federation/schema.py +++ b/strawberry/federation/schema.py @@ -1,6 +1,6 @@ from collections import defaultdict from copy import copy -from functools import partial +from functools import cached_property, partial from itertools import chain from typing import ( TYPE_CHECKING, @@ -31,7 +31,6 @@ from strawberry.printer import print_schema from strawberry.schema import Schema as BaseSchema from strawberry.types.types import StrawberryObjectDefinition -from strawberry.utils.cached_property import cached_property from strawberry.utils.inspect import get_func_args from .schema_directive import StrawberryFederationSchemaDirective diff --git a/strawberry/field.py b/strawberry/field.py index 377fecf1a6..76dbd4184c 100644 --- a/strawberry/field.py +++ b/strawberry/field.py @@ -5,6 +5,7 @@ import dataclasses import inspect import sys +from functools import cached_property from typing import ( TYPE_CHECKING, Any, @@ -30,7 +31,6 @@ has_object_definition, ) from strawberry.union import StrawberryUnion -from strawberry.utils.cached_property import cached_property from .types.fields.resolver import StrawberryResolver diff --git a/strawberry/relay/exceptions.py b/strawberry/relay/exceptions.py index eb872b4136..a35f74c461 100644 --- a/strawberry/relay/exceptions.py +++ b/strawberry/relay/exceptions.py @@ -1,11 +1,11 @@ from __future__ import annotations from collections.abc import Callable +from functools import cached_property from typing import TYPE_CHECKING, Optional, Type, cast from strawberry.exceptions.exception import StrawberryException from strawberry.exceptions.utils.source_finder import SourceFinder -from strawberry.utils.cached_property import cached_property if TYPE_CHECKING: from strawberry.exceptions.exception_source import ExceptionSource diff --git a/strawberry/schema/base.py b/strawberry/schema/base.py index 74c0de4356..a1c286c6d0 100644 --- a/strawberry/schema/base.py +++ b/strawberry/schema/base.py @@ -79,7 +79,7 @@ def get_type_by_name( raise NotImplementedError @abstractmethod - @lru_cache() + @lru_cache def get_directive_by_name(self, graphql_name: str) -> Optional[StrawberryDirective]: raise NotImplementedError diff --git a/strawberry/schema/schema.py b/strawberry/schema/schema.py index 1c6a9254a4..8a4c538ee7 100644 --- a/strawberry/schema/schema.py +++ b/strawberry/schema/schema.py @@ -184,7 +184,7 @@ def get_extensions( return extensions - @lru_cache() + @lru_cache def get_type_by_name( self, name: str ) -> Optional[ @@ -220,7 +220,7 @@ def get_field_for_type( None, ) - @lru_cache() + @lru_cache def get_directive_by_name(self, graphql_name: str) -> Optional[StrawberryDirective]: return next( ( diff --git a/strawberry/types/fields/resolver.py b/strawberry/types/fields/resolver.py index 1c1cfaf12c..baf101c34e 100644 --- a/strawberry/types/fields/resolver.py +++ b/strawberry/types/fields/resolver.py @@ -3,6 +3,7 @@ import inspect import sys import warnings +from functools import cached_property from inspect import isasyncgenfunction, iscoroutinefunction from typing import ( TYPE_CHECKING, @@ -26,7 +27,6 @@ from strawberry.exceptions import MissingArgumentsAnnotationsError from strawberry.type import StrawberryType, has_object_definition from strawberry.types.info import Info -from strawberry.utils.cached_property import cached_property if TYPE_CHECKING: import builtins diff --git a/strawberry/types/info.py b/strawberry/types/info.py index d1607d7302..288957540d 100644 --- a/strawberry/types/info.py +++ b/strawberry/types/info.py @@ -2,6 +2,7 @@ import dataclasses import warnings +from functools import cached_property from typing import ( TYPE_CHECKING, Any, @@ -14,8 +15,6 @@ Union, ) -from strawberry.utils.cached_property import cached_property - from .nodes import convert_selections if TYPE_CHECKING: diff --git a/strawberry/utils/cached_property.py b/strawberry/utils/cached_property.py deleted file mode 100644 index 21f6f43db7..0000000000 --- a/strawberry/utils/cached_property.py +++ /dev/null @@ -1,38 +0,0 @@ -import sys -from typing import TYPE_CHECKING - -if sys.version_info < (3, 8): - from backports.cached_property import cached_property -else: - from functools import cached_property - -if TYPE_CHECKING: - from threading import RLock - from typing import Any, Callable, Generic, Optional, Type, TypeVar, overload - - _T = TypeVar("_T") - _S = TypeVar("_S") - - class cached_property(Generic[_T]): # type: ignore[no-redef] - func: Callable[[Any], _T] - attrname: Optional[str] - lock: RLock - - def __init__(self, func: Callable[[Any], _T]) -> None: - ... - - @overload # type: ignore[no-overload-impl] - def __get__( - self, instance: None, owner: Optional[Type[Any]] = ... - ) -> cached_property[_T]: - ... - - @overload - def __get__(self, instance: _S, owner: Optional[Type[Any]] = ...) -> _T: - ... - - def __set_name__(self, owner: Type[Any], name: str) -> None: - ... - - -__all__ = ["cached_property"] diff --git a/strawberry/utils/logging.py b/strawberry/utils/logging.py index d7b225d645..612a5af98b 100644 --- a/strawberry/utils/logging.py +++ b/strawberry/utils/logging.py @@ -1,11 +1,10 @@ from __future__ import annotations import logging -import sys from typing import TYPE_CHECKING, Any, Optional if TYPE_CHECKING: - from typing_extensions import Final + from typing import Final from graphql.error import GraphQLError @@ -29,7 +28,6 @@ def error( # stacklevel was added in version 3.8 # https://docs.python.org/3/library/logging.html#logging.Logger.debug - if sys.version_info >= (3, 8): - logger_kwargs["stacklevel"] = 3 + logger_kwargs["stacklevel"] = 3 cls.logger.error(error, exc_info=error.original_error, **logger_kwargs) diff --git a/strawberry/utils/typing.py b/strawberry/utils/typing.py index f7a97dde03..ca8645b9a4 100644 --- a/strawberry/utils/typing.py +++ b/strawberry/utils/typing.py @@ -37,7 +37,7 @@ ast_unparse = astunparse.unparse -@lru_cache() +@lru_cache def get_generic_alias(type_: Type) -> Type: """Get the generic alias for a type. diff --git a/tests/exceptions/test_threading_exception_handler.py b/tests/exceptions/test_threading_exception_handler.py index 7f969f301d..7d826f1889 100644 --- a/tests/exceptions/test_threading_exception_handler.py +++ b/tests/exceptions/test_threading_exception_handler.py @@ -1,9 +1,6 @@ import os -import sys import threading -import pytest - from strawberry.exceptions import MissingFieldAnnotationError from strawberry.exceptions.handler import ( reset_exception_handler, @@ -83,9 +80,6 @@ class Query: ) -@pytest.mark.skipif( - sys.version_info < (3, 8), reason="threading.excepthook is only available in 3.8+" -) def test_setup_install_handler(mocker): reset_exception_handler() setup_exception_handler() @@ -93,17 +87,6 @@ def test_setup_install_handler(mocker): assert threading.excepthook == strawberry_threading_exception_handler -@pytest.mark.skipif(sys.version_info >= (3, 8), reason="test for python < 3.8") -def test_setup_install_handler_does_add_attribute(mocker): - reset_exception_handler() - setup_exception_handler() - - assert hasattr(threading, "excepthook") is False - - -@pytest.mark.skipif( - sys.version_info < (3, 8), reason="threading.excepthook is only available in 3.8+" -) def test_setup_does_not_install_handler_when_disabled_via_env(mocker): reset_exception_handler() diff --git a/tests/starlite/test_context.py b/tests/starlite/test_context.py index f95a105ac8..9b33127c4b 100644 --- a/tests/starlite/test_context.py +++ b/tests/starlite/test_context.py @@ -1,8 +1,5 @@ -import sys from typing import Any, Dict -import pytest - import strawberry try: @@ -15,11 +12,6 @@ pass -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 8), reason="requires python3.8 or higher" -) - - def test_base_context(): base_context = BaseContext() assert base_context.request is None diff --git a/tests/starlite/test_response_headers.py b/tests/starlite/test_response_headers.py index 5a5b0705d2..6f1ae1cb36 100644 --- a/tests/starlite/test_response_headers.py +++ b/tests/starlite/test_response_headers.py @@ -1,7 +1,3 @@ -import sys - -import pytest - import strawberry from strawberry.types import Info @@ -13,11 +9,6 @@ pass -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 8), reason="requires python3.8 or higher" -) - - # TODO: move this to common tests def test_set_response_headers(): @strawberry.type diff --git a/tests/starlite/test_response_status.py b/tests/starlite/test_response_status.py index f3dd710ca0..38ba209378 100644 --- a/tests/starlite/test_response_status.py +++ b/tests/starlite/test_response_status.py @@ -1,7 +1,3 @@ -import sys - -import pytest - import strawberry from strawberry.types import Info @@ -13,11 +9,6 @@ pass -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 8), reason="requires python3.8 or higher" -) - - # TODO: move this to common tests def test_set_custom_http_response_status(): @strawberry.type diff --git a/tests/starlite/test_websockets.py b/tests/starlite/test_websockets.py index 4d22b8cdbd..97c6e482d0 100644 --- a/tests/starlite/test_websockets.py +++ b/tests/starlite/test_websockets.py @@ -1,5 +1,3 @@ -import sys - import pytest from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL @@ -12,11 +10,6 @@ pass -pytestmark = pytest.mark.skipif( - sys.version_info < (3, 8), reason="requires python3.8 or higher" -) - - def test_turning_off_graphql_ws(): app = create_app(subscription_protocols=[GRAPHQL_TRANSPORT_WS_PROTOCOL]) test_client = TestClient(app) diff --git a/tests/websockets/test_graphql_transport_ws.py b/tests/websockets/test_graphql_transport_ws.py index d52ce46652..3b56e594b7 100644 --- a/tests/websockets/test_graphql_transport_ws.py +++ b/tests/websockets/test_graphql_transport_ws.py @@ -3,7 +3,6 @@ import asyncio import contextlib import json -import sys import time from datetime import timedelta from typing import TYPE_CHECKING, Any, AsyncGenerator, Type @@ -168,10 +167,6 @@ async def test_connection_init_timeout_cancellation( ) -@pytest.mark.skipif( - sys.version_info < (3, 8), - reason="Task name was introduced in 3.8 and we need it for this test", -) async def test_close_twice( mocker: MockerFixture, request: Any, http_client_class: Type[HttpClient] ):