Skip to content

Commit

Permalink
refactor: import cached_property directly from functools
Browse files Browse the repository at this point in the history
  • Loading branch information
bellini666 committed Jul 31, 2023
1 parent 2d2b56e commit 561e428
Show file tree
Hide file tree
Showing 26 changed files with 25 additions and 71 deletions.
2 changes: 1 addition & 1 deletion strawberry/channels/handlers/http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion strawberry/directive.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -13,7 +14,6 @@
StrawberryResolver,
)
from strawberry.unset import UNSET
from strawberry.utils.cached_property import cached_property

if TYPE_CHECKING:
import inspect
Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/duplicated_type_name.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion strawberry/exceptions/exception.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 1 addition & 1 deletion strawberry/exceptions/invalid_argument_type.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion strawberry/exceptions/invalid_union_type.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/missing_arguments_annotations.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/missing_field_annotation.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/missing_return_annotation.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/not_a_strawberry_enum.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/object_is_not_a_class.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/object_is_not_an_enum.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/private_strawberry_field.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion strawberry/exceptions/scalar_already_registered.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion strawberry/exceptions/unresolved_field_type.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 1 addition & 2 deletions strawberry/exceptions/utils/source_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions strawberry/extensions/field_extension.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion strawberry/extensions/tracing/datadog.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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

from ddtrace import Span, tracer

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
Expand Down
2 changes: 1 addition & 1 deletion strawberry/extensions/tracing/sentry.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from __future__ import annotations

import hashlib
from functools import cached_property
from inspect import isawaitable
from typing import TYPE_CHECKING, Any, Callable, Generator, Optional

from sentry_sdk import configure_scope, start_span

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
Expand Down
3 changes: 1 addition & 2 deletions strawberry/federation/schema.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion strawberry/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import dataclasses
import inspect
import sys
from functools import cached_property
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion strawberry/relay/exceptions.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion strawberry/types/fields/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions strawberry/types/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dataclasses
import warnings
from functools import cached_property
from typing import (
TYPE_CHECKING,
Any,
Expand All @@ -14,8 +15,6 @@
Union,
)

from strawberry.utils.cached_property import cached_property

from .nodes import convert_selections

if TYPE_CHECKING:
Expand Down
33 changes: 0 additions & 33 deletions strawberry/utils/cached_property.py

This file was deleted.

0 comments on commit 561e428

Please sign in to comment.