Skip to content

Commit 4720f77

Browse files
authored
Merge pull request #730 from dan98765/add_pre_commit_tool_to_repo
Add pre-commit tool to repository, and run on all files
2 parents 12d4dab + 9777184 commit 4720f77

14 files changed

+96
-35
lines changed

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
- repo: git://github.com/pre-commit/pre-commit-hooks
2+
sha: v0.8.0
3+
hooks:
4+
- id: autopep8-wrapper
5+
args:
6+
- -i
7+
- --ignore=E128,E309,E501
8+
exclude: ^docs/.*$
9+
- id: check-json
10+
- id: check-yaml
11+
- id: debug-statements
12+
- id: end-of-file-fixer
13+
exclude: ^docs/.*$
14+
- id: trailing-whitespace
15+
- id: pretty-format-json
16+
args:
17+
- --autofix

UPGRADE-v2.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ Now you can create abstact types super easily, without the need of subclassing t
278278
class Base(ObjectType):
279279
class Meta:
280280
abstract = True
281-
281+
282282
id = ID()
283283

284284
def resolve_id(self, info):

examples/complex_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def resolve_address(self, info, geo):
2222

2323

2424
class CreateAddress(graphene.Mutation):
25-
25+
2626
class Arguments:
2727
geo = GeoInput(required=True)
2828

graphene/pyutils/enum.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,19 +662,25 @@ def __new__(cls, value):
662662
if member.value == value:
663663
return member
664664
raise ValueError("%s is not a valid %s" % (value, cls.__name__))
665+
666+
665667
temp_enum_dict['__new__'] = __new__
666668
del __new__
667669

668670

669671
def __repr__(self):
670672
return "<%s.%s: %r>" % (
671673
self.__class__.__name__, self._name_, self._value_)
674+
675+
672676
temp_enum_dict['__repr__'] = __repr__
673677
del __repr__
674678

675679

676680
def __str__(self):
677681
return "%s.%s" % (self.__class__.__name__, self._name_)
682+
683+
678684
temp_enum_dict['__str__'] = __str__
679685
del __str__
680686

@@ -705,6 +711,8 @@ def __format__(self, format_spec):
705711
cls = self._member_type_
706712
val = self.value
707713
return cls.__format__(val, format_spec)
714+
715+
708716
temp_enum_dict['__format__'] = __format__
709717
del __format__
710718

@@ -751,6 +759,8 @@ def __eq__(self, other):
751759
if isinstance(other, self.__class__):
752760
return self is other
753761
return NotImplemented
762+
763+
754764
temp_enum_dict['__eq__'] = __eq__
755765
del __eq__
756766

@@ -759,18 +769,24 @@ def __ne__(self, other):
759769
if isinstance(other, self.__class__):
760770
return self is not other
761771
return NotImplemented
772+
773+
762774
temp_enum_dict['__ne__'] = __ne__
763775
del __ne__
764776

765777

766778
def __hash__(self):
767779
return hash(self._name_)
780+
781+
768782
temp_enum_dict['__hash__'] = __hash__
769783
del __hash__
770784

771785

772786
def __reduce_ex__(self, proto):
773787
return self.__class__, (self._value_, )
788+
789+
774790
temp_enum_dict['__reduce_ex__'] = __reduce_ex__
775791
del __reduce_ex__
776792

@@ -785,13 +801,17 @@ def __reduce_ex__(self, proto):
785801
@_RouteClassAttributeToGetattr
786802
def name(self):
787803
return self._name_
804+
805+
788806
temp_enum_dict['name'] = name
789807
del name
790808

791809

792810
@_RouteClassAttributeToGetattr
793811
def value(self):
794812
return self._value_
813+
814+
795815
temp_enum_dict['value'] = value
796816
del value
797817

@@ -817,6 +837,8 @@ def _convert(cls, name, module, filter, source=None):
817837
module_globals.update(cls.__members__)
818838
module_globals[name] = cls
819839
return cls
840+
841+
820842
temp_enum_dict['_convert'] = _convert
821843
del _convert
822844

graphene/pyutils/signature.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def formatannotation(annotation, base_module=None):
2828
if isinstance(annotation, type):
2929
if annotation.__module__ in ('builtins', '__builtin__', base_module):
3030
return annotation.__name__
31-
return annotation.__module__+'.'+annotation.__name__
31+
return annotation.__module__ + '.' + annotation.__name__
3232
return repr(annotation)
3333

3434

@@ -126,7 +126,7 @@ def signature(obj):
126126
_partial_kwarg=True)
127127

128128
elif (param.kind not in (_VAR_KEYWORD, _VAR_POSITIONAL) and
129-
not param._partial_kwarg):
129+
not param._partial_kwarg):
130130
new_params.pop(arg_name)
131131

132132
return sig.replace(parameters=new_params.values())
@@ -193,11 +193,11 @@ def __repr__(self):
193193
return '<_ParameterKind: {0!r}>'.format(self._name)
194194

195195

196-
_POSITIONAL_ONLY = _ParameterKind(0, name='POSITIONAL_ONLY')
197-
_POSITIONAL_OR_KEYWORD = _ParameterKind(1, name='POSITIONAL_OR_KEYWORD')
198-
_VAR_POSITIONAL = _ParameterKind(2, name='VAR_POSITIONAL')
199-
_KEYWORD_ONLY = _ParameterKind(3, name='KEYWORD_ONLY')
200-
_VAR_KEYWORD = _ParameterKind(4, name='VAR_KEYWORD')
196+
_POSITIONAL_ONLY = _ParameterKind(0, name='POSITIONAL_ONLY')
197+
_POSITIONAL_OR_KEYWORD = _ParameterKind(1, name='POSITIONAL_OR_KEYWORD')
198+
_VAR_POSITIONAL = _ParameterKind(2, name='VAR_POSITIONAL')
199+
_KEYWORD_ONLY = _ParameterKind(3, name='KEYWORD_ONLY')
200+
_VAR_KEYWORD = _ParameterKind(4, name='VAR_KEYWORD')
201201

202202

203203
class Parameter(object):
@@ -220,11 +220,11 @@ class Parameter(object):
220220

221221
__slots__ = ('_name', '_kind', '_default', '_annotation', '_partial_kwarg')
222222

223-
POSITIONAL_ONLY = _POSITIONAL_ONLY
224-
POSITIONAL_OR_KEYWORD = _POSITIONAL_OR_KEYWORD
225-
VAR_POSITIONAL = _VAR_POSITIONAL
226-
KEYWORD_ONLY = _KEYWORD_ONLY
227-
VAR_KEYWORD = _VAR_KEYWORD
223+
POSITIONAL_ONLY = _POSITIONAL_ONLY
224+
POSITIONAL_OR_KEYWORD = _POSITIONAL_OR_KEYWORD
225+
VAR_POSITIONAL = _VAR_POSITIONAL
226+
KEYWORD_ONLY = _KEYWORD_ONLY
227+
VAR_KEYWORD = _VAR_KEYWORD
228228

229229
empty = _empty
230230

@@ -366,7 +366,7 @@ def args(self):
366366
args = []
367367
for param_name, param in self._signature.parameters.items():
368368
if (param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY) or
369-
param._partial_kwarg):
369+
param._partial_kwarg):
370370
# Keyword arguments mapped by 'functools.partial'
371371
# (Parameter._partial_kwarg is True) are mapped
372372
# in 'BoundArguments.kwargs', along with VAR_KEYWORD &
@@ -396,7 +396,7 @@ def kwargs(self):
396396
for param_name, param in self._signature.parameters.items():
397397
if not kwargs_started:
398398
if (param.kind in (_VAR_KEYWORD, _KEYWORD_ONLY) or
399-
param._partial_kwarg):
399+
param._partial_kwarg):
400400
kwargs_started = True
401401
else:
402402
if param_name not in self.arguments:
@@ -494,7 +494,7 @@ def __init__(self, parameters=None, return_annotation=_empty,
494494
params[name] = param
495495
else:
496496
params = OrderedDict(((param.name, param)
497-
for param in parameters))
497+
for param in parameters))
498498

499499
self._parameters = params
500500
self._return_annotation = return_annotation
@@ -604,8 +604,8 @@ def __hash__(self):
604604

605605
def __eq__(self, other):
606606
if (not issubclass(type(other), Signature) or
607-
self.return_annotation != other.return_annotation or
608-
len(self.parameters) != len(other.parameters)):
607+
self.return_annotation != other.return_annotation or
608+
len(self.parameters) != len(other.parameters)):
609609
return False
610610

611611
other_positions = dict((param, idx)
@@ -627,7 +627,7 @@ def __eq__(self, other):
627627
return False
628628
else:
629629
if (idx != other_idx or
630-
param != other.parameters[param_name]):
630+
param != other.parameters[param_name]):
631631
return False
632632

633633
return True
@@ -680,7 +680,7 @@ def _bind(self, args, kwargs, partial=False):
680680
parameters_ex = (param,)
681681
break
682682
elif (param.kind == _VAR_KEYWORD or
683-
param.default is not _empty):
683+
param.default is not _empty):
684684
# That's fine too - we have a default value for this
685685
# parameter. So, lets start parsing `kwargs`, starting
686686
# with the current parameter
@@ -730,7 +730,7 @@ def _bind(self, args, kwargs, partial=False):
730730
# Signature object (but let's have this check here
731731
# to ensure correct behaviour just in case)
732732
raise TypeError('{arg!r} parameter is positional only, '
733-
'but was passed as a keyword'. \
733+
'but was passed as a keyword'.
734734
format(arg=param.name))
735735

736736
if param.kind == _VAR_KEYWORD:
@@ -747,8 +747,8 @@ def _bind(self, args, kwargs, partial=False):
747747
# parameter, left alone by the processing of positional
748748
# arguments.
749749
if (not partial and param.kind != _VAR_POSITIONAL and
750-
param.default is _empty):
751-
raise TypeError('{arg!r} parameter lacking default value'. \
750+
param.default is _empty):
751+
raise TypeError('{arg!r} parameter lacking default value'.
752752
format(arg=param_name))
753753

754754
else:

graphene/relay/tests/test_node_custom.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Meta:
5454
class RootQuery(ObjectType):
5555
node = CustomNode.Field()
5656

57+
5758
schema = Schema(query=RootQuery, types=[User, Photo])
5859

5960

graphene/types/tests/test_base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init_subclass_with_meta__(cls, **options):
1717
def test_basetype():
1818
class MyBaseType(CustomType):
1919
pass
20-
20+
2121
assert isinstance(MyBaseType._meta, CustomOptions)
2222
assert MyBaseType._meta.name == "MyBaseType"
2323
assert MyBaseType._meta.description is None

graphene/types/tests/test_datetime.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,27 @@ def test_time_query():
5555
assert not result.errors
5656
assert result.data == {'time': isoformat}
5757

58+
5859
def test_bad_datetime_query():
5960
not_a_date = "Some string that's not a date"
6061

6162
result = schema.execute('''{ datetime(in: "%s") }''' % not_a_date)
62-
63+
6364
assert len(result.errors) == 1
6465
assert isinstance(result.errors[0], GraphQLError)
6566
assert result.data == None
6667

68+
6769
def test_bad_date_query():
6870
not_a_date = "Some string that's not a date"
69-
71+
7072
result = schema.execute('''{ date(in: "%s") }''' % not_a_date)
71-
73+
7274
assert len(result.errors) == 1
7375
assert isinstance(result.errors[0], GraphQLError)
7476
assert result.data == None
7577

78+
7679
def test_bad_time_query():
7780
not_a_date = "Some string that's not a date"
7881

@@ -82,6 +85,7 @@ def test_bad_time_query():
8285
assert isinstance(result.errors[0], GraphQLError)
8386
assert result.data == None
8487

88+
8589
def test_datetime_query_variable():
8690
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
8791
isoformat = now.isoformat()

graphene/types/tests/test_json.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Query(ObjectType):
1010
def resolve_json(self, info, input):
1111
return input
1212

13+
1314
schema = Schema(query=Query)
1415

1516

graphene/types/tests/test_uuid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Query(ObjectType):
99
def resolve_uuid(self, info, input):
1010
return input
1111

12+
1213
schema = Schema(query=Query)
1314

1415

graphene/utils/tests/test_annotate.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
import pytest
22
from ..annotate import annotate
33

4+
45
def func(a, b, *c, **d):
56
pass
67

8+
79
annotations = {
810
'a': int,
911
'b': str,
1012
'c': list,
1113
'd': dict
1214
}
1315

16+
1417
def func_with_annotations(a, b, *c, **d):
1518
pass
19+
20+
1621
func_with_annotations.__annotations__ = annotations
1722

1823

0 commit comments

Comments
 (0)