mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 04:07:16 +03:00
run linters locally
This commit is contained in:
parent
2e5944eb20
commit
47696559c7
|
@ -291,14 +291,7 @@ class Field:
|
|||
|
||||
|
||||
class _DataclassParams:
|
||||
__slots__ = (
|
||||
"init",
|
||||
"repr",
|
||||
"eq",
|
||||
"order",
|
||||
"unsafe_hash",
|
||||
"frozen",
|
||||
)
|
||||
__slots__ = ("init", "repr", "eq", "order", "unsafe_hash", "frozen")
|
||||
|
||||
def __init__(self, init, repr, eq, order, unsafe_hash, frozen):
|
||||
self.init = init
|
||||
|
@ -1157,10 +1150,7 @@ def make_dataclass(
|
|||
name = item
|
||||
tp = "typing.Any"
|
||||
elif len(item) == 2:
|
||||
(
|
||||
name,
|
||||
tp,
|
||||
) = item
|
||||
(name, tp) = item
|
||||
elif len(item) == 3:
|
||||
name, tp, spec = item
|
||||
namespace[name] = spec
|
||||
|
|
|
@ -92,11 +92,9 @@ class Node(AbstractNode):
|
|||
_type, _id = cls.from_global_id(global_id)
|
||||
except Exception as e:
|
||||
raise Exception(
|
||||
(
|
||||
f'Unable to parse global ID "{global_id}". '
|
||||
'Make sure it is a base64 encoded string in the format: "TypeName:id". '
|
||||
f"Exception message: {str(e)}"
|
||||
)
|
||||
f'Unable to parse global ID "{global_id}". '
|
||||
'Make sure it is a base64 encoded string in the format: "TypeName:id". '
|
||||
f"Exception message: {str(e)}"
|
||||
)
|
||||
|
||||
graphene_type = info.schema.get_type(_type)
|
||||
|
|
|
@ -163,16 +163,14 @@ async def test_respects_first_and_after_and_before_too_few():
|
|||
@mark.asyncio
|
||||
async def test_respects_first_and_after_and_before_too_many():
|
||||
await check(
|
||||
f'first: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
|
||||
"BCD",
|
||||
f'first: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
|
||||
)
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_respects_first_and_after_and_before_exactly_right():
|
||||
await check(
|
||||
f'first: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
|
||||
"BCD",
|
||||
f'first: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
|
||||
)
|
||||
|
||||
|
||||
|
@ -188,16 +186,14 @@ async def test_respects_last_and_after_and_before_too_few():
|
|||
@mark.asyncio
|
||||
async def test_respects_last_and_after_and_before_too_many():
|
||||
await check(
|
||||
f'last: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
|
||||
"BCD",
|
||||
f'last: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
|
||||
)
|
||||
|
||||
|
||||
@mark.asyncio
|
||||
async def test_respects_last_and_after_and_before_exactly_right():
|
||||
await check(
|
||||
f'last: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"',
|
||||
"BCD",
|
||||
f'last: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -96,12 +96,10 @@ class Mutation(ObjectType):
|
|||
input_class = getattr(cls, "Input", None)
|
||||
if input_class:
|
||||
warn_deprecation(
|
||||
(
|
||||
f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input."
|
||||
" Input is now only used in ClientMutationID.\n"
|
||||
"Read more:"
|
||||
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
|
||||
)
|
||||
f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input."
|
||||
" Input is now only used in ClientMutationID.\n"
|
||||
"Read more:"
|
||||
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
|
||||
)
|
||||
if input_class:
|
||||
arguments = props(input_class)
|
||||
|
|
|
@ -27,11 +27,7 @@ class ObjectTypeMeta(BaseTypeMeta):
|
|||
pass
|
||||
|
||||
base_cls = super().__new__(
|
||||
cls,
|
||||
name_,
|
||||
(InterObjectType,) + bases,
|
||||
namespace,
|
||||
**options,
|
||||
cls, name_, (InterObjectType,) + bases, namespace, **options
|
||||
)
|
||||
if base_cls._meta:
|
||||
fields = [
|
||||
|
|
|
@ -64,16 +64,11 @@ def test_base64_query_none():
|
|||
|
||||
|
||||
def test_base64_query_invalid():
|
||||
bad_inputs = [
|
||||
dict(),
|
||||
123,
|
||||
"This is not valid base64",
|
||||
]
|
||||
bad_inputs = [dict(), 123, "This is not valid base64"]
|
||||
|
||||
for input_ in bad_inputs:
|
||||
result = schema.execute(
|
||||
"""{ base64(input: $input) }""",
|
||||
variables={"input": input_},
|
||||
"""{ base64(input: $input) }""", variables={"input": input_}
|
||||
)
|
||||
assert isinstance(result.errors, list)
|
||||
assert len(result.errors) == 1
|
||||
|
|
|
@ -26,8 +26,8 @@ def test_enum_construction():
|
|||
assert RGB._meta.description == "Description"
|
||||
|
||||
values = RGB._meta.enum.__members__.values()
|
||||
assert sorted([v.name for v in values]) == ["BLUE", "GREEN", "RED"]
|
||||
assert sorted([v.description for v in values]) == [
|
||||
assert sorted(v.name for v in values) == ["BLUE", "GREEN", "RED"]
|
||||
assert sorted(v.description for v in values) == [
|
||||
"Description BLUE",
|
||||
"Description GREEN",
|
||||
"Description RED",
|
||||
|
@ -52,7 +52,7 @@ def test_enum_instance_construction():
|
|||
RGB = Enum("RGB", "RED,GREEN,BLUE")
|
||||
|
||||
values = RGB._meta.enum.__members__.values()
|
||||
assert sorted([v.name for v in values]) == ["BLUE", "GREEN", "RED"]
|
||||
assert sorted(v.name for v in values) == ["BLUE", "GREEN", "RED"]
|
||||
|
||||
|
||||
def test_enum_from_builtin_enum():
|
||||
|
@ -465,7 +465,7 @@ def test_mutation_enum_input_type():
|
|||
color
|
||||
}
|
||||
}
|
||||
""",
|
||||
"""
|
||||
)
|
||||
assert not result.errors
|
||||
assert result.data == {"createPaint": {"color": "RED"}}
|
||||
|
|
|
@ -36,4 +36,4 @@ class OrderedType:
|
|||
return NotImplemented
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.creation_counter))
|
||||
return hash(self.creation_counter)
|
||||
|
|
|
@ -11,7 +11,6 @@ class DisableIntrospection(ValidationRule):
|
|||
if is_introspection_key(field_name):
|
||||
self.report_error(
|
||||
GraphQLError(
|
||||
f"Cannot query '{field_name}': introspection is disabled.",
|
||||
node,
|
||||
f"Cannot query '{field_name}': introspection is disabled.", node
|
||||
)
|
||||
)
|
||||
|
|
|
@ -236,11 +236,7 @@ def test_should_ignore_field():
|
|||
errors, result = run_query(
|
||||
query,
|
||||
10,
|
||||
ignore=[
|
||||
"user1",
|
||||
re.compile("user2"),
|
||||
lambda field_name: field_name == "user3",
|
||||
],
|
||||
ignore=["user1", re.compile("user2"), lambda field_name: field_name == "user3"],
|
||||
)
|
||||
|
||||
expected = {"read1": 2, "read2": 0}
|
||||
|
@ -255,8 +251,4 @@ def test_should_raise_invalid_ignore():
|
|||
}
|
||||
"""
|
||||
with raises(ValueError, match="Invalid ignore option:"):
|
||||
run_query(
|
||||
query,
|
||||
10,
|
||||
ignore=[True],
|
||||
)
|
||||
run_query(query, 10, ignore=[True])
|
||||
|
|
Loading…
Reference in New Issue
Block a user