run linters locally

This commit is contained in:
Aryan Iyappan 2021-08-24 08:30:54 +05:30
parent 2e5944eb20
commit 47696559c7
10 changed files with 24 additions and 60 deletions

View File

@ -291,14 +291,7 @@ class Field:
class _DataclassParams: class _DataclassParams:
__slots__ = ( __slots__ = ("init", "repr", "eq", "order", "unsafe_hash", "frozen")
"init",
"repr",
"eq",
"order",
"unsafe_hash",
"frozen",
)
def __init__(self, init, repr, eq, order, unsafe_hash, frozen): def __init__(self, init, repr, eq, order, unsafe_hash, frozen):
self.init = init self.init = init
@ -1157,10 +1150,7 @@ def make_dataclass(
name = item name = item
tp = "typing.Any" tp = "typing.Any"
elif len(item) == 2: elif len(item) == 2:
( (name, tp) = item
name,
tp,
) = item
elif len(item) == 3: elif len(item) == 3:
name, tp, spec = item name, tp, spec = item
namespace[name] = spec namespace[name] = spec

View File

@ -92,11 +92,9 @@ class Node(AbstractNode):
_type, _id = cls.from_global_id(global_id) _type, _id = cls.from_global_id(global_id)
except Exception as e: except Exception as e:
raise Exception( raise Exception(
( f'Unable to parse global ID "{global_id}". '
f'Unable to parse global ID "{global_id}". ' 'Make sure it is a base64 encoded string in the format: "TypeName:id". '
'Make sure it is a base64 encoded string in the format: "TypeName:id". ' f"Exception message: {str(e)}"
f"Exception message: {str(e)}"
)
) )
graphene_type = info.schema.get_type(_type) graphene_type = info.schema.get_type(_type)

View File

@ -163,16 +163,14 @@ async def test_respects_first_and_after_and_before_too_few():
@mark.asyncio @mark.asyncio
async def test_respects_first_and_after_and_before_too_many(): async def test_respects_first_and_after_and_before_too_many():
await check( await check(
f'first: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', f'first: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
"BCD",
) )
@mark.asyncio @mark.asyncio
async def test_respects_first_and_after_and_before_exactly_right(): async def test_respects_first_and_after_and_before_exactly_right():
await check( await check(
f'first: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', f'first: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
"BCD",
) )
@ -188,16 +186,14 @@ async def test_respects_last_and_after_and_before_too_few():
@mark.asyncio @mark.asyncio
async def test_respects_last_and_after_and_before_too_many(): async def test_respects_last_and_after_and_before_too_many():
await check( await check(
f'last: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', f'last: 4, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
"BCD",
) )
@mark.asyncio @mark.asyncio
async def test_respects_last_and_after_and_before_exactly_right(): async def test_respects_last_and_after_and_before_exactly_right():
await check( await check(
f'last: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', f'last: 3, after: "{cursor_for("A")}", before: "{cursor_for("E")}"', "BCD"
"BCD",
) )

View File

@ -96,12 +96,10 @@ class Mutation(ObjectType):
input_class = getattr(cls, "Input", None) input_class = getattr(cls, "Input", None)
if input_class: if input_class:
warn_deprecation( warn_deprecation(
( f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input."
f"Please use {cls.__name__}.Arguments instead of {cls.__name__}.Input." " Input is now only used in ClientMutationID.\n"
" Input is now only used in ClientMutationID.\n" "Read more:"
"Read more:" " https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
)
) )
if input_class: if input_class:
arguments = props(input_class) arguments = props(input_class)

View File

@ -27,11 +27,7 @@ class ObjectTypeMeta(BaseTypeMeta):
pass pass
base_cls = super().__new__( base_cls = super().__new__(
cls, cls, name_, (InterObjectType,) + bases, namespace, **options
name_,
(InterObjectType,) + bases,
namespace,
**options,
) )
if base_cls._meta: if base_cls._meta:
fields = [ fields = [

View File

@ -64,16 +64,11 @@ def test_base64_query_none():
def test_base64_query_invalid(): def test_base64_query_invalid():
bad_inputs = [ bad_inputs = [dict(), 123, "This is not valid base64"]
dict(),
123,
"This is not valid base64",
]
for input_ in bad_inputs: for input_ in bad_inputs:
result = schema.execute( result = schema.execute(
"""{ base64(input: $input) }""", """{ base64(input: $input) }""", variables={"input": input_}
variables={"input": input_},
) )
assert isinstance(result.errors, list) assert isinstance(result.errors, list)
assert len(result.errors) == 1 assert len(result.errors) == 1

View File

@ -26,8 +26,8 @@ def test_enum_construction():
assert RGB._meta.description == "Description" assert RGB._meta.description == "Description"
values = RGB._meta.enum.__members__.values() 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"]
assert sorted([v.description for v in values]) == [ assert sorted(v.description for v in values) == [
"Description BLUE", "Description BLUE",
"Description GREEN", "Description GREEN",
"Description RED", "Description RED",
@ -52,7 +52,7 @@ def test_enum_instance_construction():
RGB = Enum("RGB", "RED,GREEN,BLUE") RGB = Enum("RGB", "RED,GREEN,BLUE")
values = RGB._meta.enum.__members__.values() 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(): def test_enum_from_builtin_enum():
@ -465,7 +465,7 @@ def test_mutation_enum_input_type():
color color
} }
} }
""", """
) )
assert not result.errors assert not result.errors
assert result.data == {"createPaint": {"color": "RED"}} assert result.data == {"createPaint": {"color": "RED"}}

View File

@ -36,4 +36,4 @@ class OrderedType:
return NotImplemented return NotImplemented
def __hash__(self): def __hash__(self):
return hash((self.creation_counter)) return hash(self.creation_counter)

View File

@ -11,7 +11,6 @@ class DisableIntrospection(ValidationRule):
if is_introspection_key(field_name): if is_introspection_key(field_name):
self.report_error( self.report_error(
GraphQLError( GraphQLError(
f"Cannot query '{field_name}': introspection is disabled.", f"Cannot query '{field_name}': introspection is disabled.", node
node,
) )
) )

View File

@ -236,11 +236,7 @@ def test_should_ignore_field():
errors, result = run_query( errors, result = run_query(
query, query,
10, 10,
ignore=[ ignore=["user1", re.compile("user2"), lambda field_name: field_name == "user3"],
"user1",
re.compile("user2"),
lambda field_name: field_name == "user3",
],
) )
expected = {"read1": 2, "read2": 0} expected = {"read1": 2, "read2": 0}
@ -255,8 +251,4 @@ def test_should_raise_invalid_ignore():
} }
""" """
with raises(ValueError, match="Invalid ignore option:"): with raises(ValueError, match="Invalid ignore option:"):
run_query( run_query(query, 10, ignore=[True])
query,
10,
ignore=[True],
)