Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions pydrawise/schema_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,15 @@

from collections import namedtuple
from dataclasses import fields, is_dataclass
from typing import Iterator, List, Type, Union, get_args, get_origin, get_type_hints
from typing import (
TYPE_CHECKING,
Iterator,
List,
Union,
get_args,
get_origin,
get_type_hints,
)

from apischema import deserialize as _deserialize
from apischema.metadata.keys import CONVERSION_METADATA, SKIP_METADATA
Expand All @@ -14,6 +22,9 @@

from .schema import DSL_SCHEMA

if TYPE_CHECKING:
from _typeshed import DataclassInstance

# For compatibility with < python 3.10.
NoneType = type(None)

Expand All @@ -30,7 +41,9 @@ def deserialize(*args, **kwargs):
_Field = namedtuple("_Field", ["name", "types"])


def _fields(cls, skip: list[str]) -> Iterator[_Field]:
def _fields(
cls: DataclassInstance | type[DataclassInstance], skip: list[str]
) -> Iterator[_Field]:
"""Returns _Field objects for every field on the given dataclass.

:meta private:
Expand Down Expand Up @@ -74,7 +87,10 @@ def _fields(cls, skip: list[str]) -> Iterator[_Field]:
yield _Field(f.name, [field_type])


def get_selectors(cls: Type, skip_fields: list[str] | None = None) -> list[DSLField]:
def get_selectors(
cls: DataclassInstance | type[DataclassInstance],
skip_fields: list[str] | None = None,
) -> list[DSLField]:
"""Constructs GraphQL selectors for the given dataclass.

:meta private:
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-r requirements.txt
aioresponses==0.7.6
freezegun==1.5.1
mypy==1.11.2
mypy==1.13.0
pytest==8.3.3
pytest-asyncio==0.24.0
ruff==0.7.1