Skip to content

Commit c592e94

Browse files
committed
Use trim_docstring to ensure description has no leading whitespace
1 parent 0dc8e57 commit c592e94

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

graphene/types/enum.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import six
44

55
from ..utils.is_base_type import is_base_type
6+
from ..utils.trim_docstring import trim_docstring
67
from .options import Options
78
from .unmountedtype import UnmountedType
89

@@ -23,7 +24,7 @@ def __new__(cls, name, bases, attrs):
2324
options = Options(
2425
attrs.pop('Meta', None),
2526
name=name,
26-
description=attrs.get('__doc__'),
27+
description=trim_docstring(attrs.get('__doc__')),
2728
enum=None,
2829
)
2930
if not options.enum:

graphene/types/inputobjecttype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import six
22

33
from ..utils.is_base_type import is_base_type
4+
from ..utils.trim_docstring import trim_docstring
45
from .abstracttype import AbstractTypeMeta
56
from .inputfield import InputField
67
from .options import Options
@@ -19,7 +20,7 @@ def __new__(cls, name, bases, attrs):
1920
options = Options(
2021
attrs.pop('Meta', None),
2122
name=name,
22-
description=attrs.get('__doc__'),
23+
description=trim_docstring(attrs.get('__doc__')),
2324
local_fields=None,
2425
)
2526

graphene/types/interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import six
22

33
from ..utils.is_base_type import is_base_type
4+
from ..utils.trim_docstring import trim_docstring
45
from .abstracttype import AbstractTypeMeta
56
from .field import Field
67
from .options import Options
@@ -18,7 +19,7 @@ def __new__(cls, name, bases, attrs):
1819
options = Options(
1920
attrs.pop('Meta', None),
2021
name=name,
21-
description=attrs.get('__doc__'),
22+
description=trim_docstring(attrs.get('__doc__')),
2223
local_fields=None,
2324
)
2425

graphene/types/objecttype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import six
44

55
from ..utils.is_base_type import is_base_type
6+
from ..utils.trim_docstring import trim_docstring
67
from .abstracttype import AbstractTypeMeta
78
from .field import Field
89
from .interface import Interface
@@ -22,7 +23,7 @@ def __new__(cls, name, bases, attrs):
2223
options = _meta or Options(
2324
attrs.pop('Meta', None),
2425
name=name,
25-
description=attrs.get('__doc__'),
26+
description=trim_docstring(attrs.get('__doc__')),
2627
interfaces=(),
2728
local_fields=OrderedDict(),
2829
)

graphene/types/scalars.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import six
2-
32
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
43
StringValue)
54

65
from ..utils.is_base_type import is_base_type
6+
from ..utils.trim_docstring import trim_docstring
77
from .options import Options
88
from .unmountedtype import UnmountedType
99

@@ -19,7 +19,7 @@ def __new__(cls, name, bases, attrs):
1919
options = Options(
2020
attrs.pop('Meta', None),
2121
name=name,
22-
description=attrs.get('__doc__'),
22+
description=trim_docstring(attrs.get('__doc__')),
2323
)
2424

2525
return type.__new__(cls, name, bases, dict(attrs, _meta=options))

graphene/types/union.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import six
22

33
from ..utils.is_base_type import is_base_type
4+
from ..utils.trim_docstring import trim_docstring
45
from .options import Options
56
from .unmountedtype import UnmountedType
67

@@ -16,7 +17,7 @@ def __new__(cls, name, bases, attrs):
1617
options = Options(
1718
attrs.pop('Meta', None),
1819
name=name,
19-
description=attrs.get('__doc__'),
20+
description=trim_docstring(attrs.get('__doc__')),
2021
types=(),
2122
)
2223

0 commit comments

Comments
 (0)