Skip to content

Commit

Permalink
Improve config for development with VS Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Jul 7, 2024
1 parent 3cf0d26 commit 6394059
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Tests
on: [push, pull_request]

jobs:
build:
tests:
runs-on: ubuntu-latest

strategy:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.tox/
.venv*/
.vs/
.vscode/

build/
dist/
Expand Down
23 changes: 21 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -274,13 +274,32 @@ disallow_untyped_defs = true

[[tool.mypy.overrides]]
module = [
"graphql.pyutils.frozen_dict",
"graphql.pyutils.frozen_list",
"graphql.type.introspection",
"tests.*"
]
disallow_untyped_defs = false

[tool.pyright]
reportIncompatibleVariableOverride = false
reportMissingTypeArgument = false
reportUnknownArgumentType = false
reportUnknownMemberType = false
reportUnknownParameterType = false
reportUnnecessaryIsInstance = false
reportUnknownVariableType = false
ignore = ["**/test_*"] # test functions

[tool.pylint.basic]
max-module-lines = 2000

[tool.pylint.messages_control]
disable = [
"method-hidden",
"missing-module-docstring", # test modules
"redefined-outer-name",
"unused-variable", # test functions
]

[tool.pytest.ini_options]
minversion = "7.4"
# Only run benchmarks as tests.
Expand Down
53 changes: 28 additions & 25 deletions src/graphql/type/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ def assert_type(type_: Any) -> GraphQLType:

# These types wrap and modify other types

GT = TypeVar("GT", bound=GraphQLType, covariant=True) # noqa: PLC0105
GT_co = TypeVar("GT_co", bound=GraphQLType, covariant=True)


class GraphQLWrappingType(GraphQLType, Generic[GT]):
class GraphQLWrappingType(GraphQLType, Generic[GT_co]):
"""Base class for all GraphQL wrapping types"""

of_type: GT
of_type: GT_co

def __init__(self, type_: GT) -> None:
def __init__(self, type_: GT_co) -> None:
self.of_type = type_

def __repr__(self) -> str:
Expand Down Expand Up @@ -255,7 +255,7 @@ def _get_instance(cls, name: str, args: tuple) -> GraphQLNamedType:
try:
return cls.reserved_types[name]
except KeyError:
return cls(**dict(args))
return cls(**dict(args)) # pyright: ignore

def __init__(
self,
Expand Down Expand Up @@ -429,8 +429,8 @@ def parse_literal(
def to_kwargs(self) -> GraphQLScalarTypeKwargs:
"""Get corresponding arguments."""
# noinspection PyArgumentList
return GraphQLScalarTypeKwargs( # type: ignore
super().to_kwargs(),
return GraphQLScalarTypeKwargs(
super().to_kwargs(), # type: ignore
serialize=None
if self.serialize is GraphQLScalarType.serialize
else self.serialize,
Expand Down Expand Up @@ -552,11 +552,11 @@ def __copy__(self) -> GraphQLField: # pragma: no cover
return self.__class__(**self.to_kwargs())


TContext = TypeVar("TContext")
TContext = TypeVar("TContext") # pylint: disable=invalid-name

try:

class GraphQLResolveInfo(NamedTuple, Generic[TContext]):
class GraphQLResolveInfo(NamedTuple, Generic[TContext]): # pyright: ignore
"""Collection of information passed to the resolvers.
This is always passed as the first argument to the resolvers.
Expand Down Expand Up @@ -768,8 +768,8 @@ def __init__(
def to_kwargs(self) -> GraphQLObjectTypeKwargs:
"""Get corresponding arguments."""
# noinspection PyArgumentList
return GraphQLObjectTypeKwargs( # type: ignore
super().to_kwargs(),
return GraphQLObjectTypeKwargs(
super().to_kwargs(), # type: ignore
fields=self.fields.copy(),
interfaces=self.interfaces,
is_type_of=self.is_type_of,
Expand Down Expand Up @@ -873,8 +873,8 @@ def __init__(
def to_kwargs(self) -> GraphQLInterfaceTypeKwargs:
"""Get corresponding arguments."""
# noinspection PyArgumentList
return GraphQLInterfaceTypeKwargs( # type: ignore
super().to_kwargs(),
return GraphQLInterfaceTypeKwargs(
super().to_kwargs(), # type: ignore
fields=self.fields.copy(),
interfaces=self.interfaces,
resolve_type=self.resolve_type,
Expand Down Expand Up @@ -978,8 +978,10 @@ def __init__(
def to_kwargs(self) -> GraphQLUnionTypeKwargs:
"""Get corresponding arguments."""
# noinspection PyArgumentList
return GraphQLUnionTypeKwargs( # type: ignore
super().to_kwargs(), types=self.types, resolve_type=self.resolve_type
return GraphQLUnionTypeKwargs(
super().to_kwargs(), # type: ignore
types=self.types,
resolve_type=self.resolve_type,
)

def __copy__(self) -> GraphQLUnionType: # pragma: no cover
Expand Down Expand Up @@ -1082,7 +1084,7 @@ def __init__(
isinstance(name, str) for name in values
):
try:
values = dict(values)
values = dict(values) # pyright: ignore
except (TypeError, ValueError) as error:
msg = (
f"{name} values must be an Enum or a mapping"
Expand All @@ -1107,8 +1109,9 @@ def __init__(
def to_kwargs(self) -> GraphQLEnumTypeKwargs:
"""Get corresponding arguments."""
# noinspection PyArgumentList
return GraphQLEnumTypeKwargs( # type: ignore
super().to_kwargs(), values=self.values.copy()
return GraphQLEnumTypeKwargs(
super().to_kwargs(), # type: ignore
values=self.values.copy(),
)

def __copy__(self) -> GraphQLEnumType: # pragma: no cover
Expand Down Expand Up @@ -1331,8 +1334,8 @@ def out_type(value: dict[str, Any]) -> Any:
def to_kwargs(self) -> GraphQLInputObjectTypeKwargs:
"""Get corresponding arguments."""
# noinspection PyArgumentList
return GraphQLInputObjectTypeKwargs( # type: ignore
super().to_kwargs(),
return GraphQLInputObjectTypeKwargs(
super().to_kwargs(), # type: ignore
fields=self.fields.copy(),
out_type=None
if self.out_type is GraphQLInputObjectType.out_type
Expand Down Expand Up @@ -1448,7 +1451,7 @@ def is_required_input_field(field: GraphQLInputField) -> bool:
# Wrapper types


class GraphQLList(GraphQLWrappingType[GT]):
class GraphQLList(GraphQLWrappingType[GT_co]):
"""List Type Wrapper
A list is a wrapping type which points to another type. Lists are often created
Expand All @@ -1467,7 +1470,7 @@ def fields(self):
}
"""

def __init__(self, type_: GT) -> None:
def __init__(self, type_: GT_co) -> None:
super().__init__(type_=type_)

def __str__(self) -> str:
Expand All @@ -1487,10 +1490,10 @@ def assert_list_type(type_: Any) -> GraphQLList:
return type_


GNT = TypeVar("GNT", bound="GraphQLNullableType", covariant=True) # noqa: PLC0105
GNT_co = TypeVar("GNT_co", bound="GraphQLNullableType", covariant=True)


class GraphQLNonNull(GraphQLWrappingType[GNT]):
class GraphQLNonNull(GraphQLWrappingType[GNT_co]):
"""Non-Null Type Wrapper
A non-null is a wrapping type which points to another type. Non-null types enforce
Expand All @@ -1510,7 +1513,7 @@ class RowType(GraphQLObjectType):
Note: the enforcement of non-nullability occurs within the executor.
"""

def __init__(self, type_: GNT) -> None:
def __init__(self, type_: GNT_co) -> None:
super().__init__(type_=type_)

def __str__(self) -> str:
Expand Down

0 comments on commit 6394059

Please sign in to comment.