style: ensure trailing commas in multi-line statements

This commit is contained in:
jakob.scheid committed 2026-09-18 22:18:13 +02:00
1 parent ffcc7404de
commit 475775eb7e
30 files changed
+1778 -1774

No files matched your search

@@ -14,11 +14,11 @@
from src.jcloud_docsgen.core.python.definitions import (
PythonFunctionDefinition,
PythonClassDefinition
PythonClassDefinition,
)
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
@@ -32,9 +32,9 @@ import pytest
[],
None,
None,
[]
[],
),
'PythonClassDefinition(\'A\', [], None, None, [])'
'PythonClassDefinition(\'A\', [], None, None, [])',
),
(
PythonClassDefinition(
@@ -42,12 +42,12 @@ import pytest
[],
None,
PythonDocstring('Hello, World!'),
[]
[],
),
(
'PythonClassDefinition(\'A\', [], None, '
'PythonDocstring(\'Hello, World!\'), [])'
)
),
),
])
def test_PythonDefinition_string_representation(definition, expected):
@@ -67,7 +67,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
@@ -76,7 +76,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
@@ -85,7 +85,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
@@ -94,7 +94,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
@@ -103,7 +103,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
@@ -112,7 +112,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
@@ -121,7 +121,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
@@ -130,7 +130,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
@@ -139,7 +139,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
@@ -148,7 +148,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
@@ -157,7 +157,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
@@ -166,7 +166,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
@@ -175,7 +175,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
@@ -184,7 +184,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
@@ -193,7 +193,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
@@ -202,7 +202,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
@@ -211,7 +211,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
@@ -220,7 +220,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
@@ -229,7 +229,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
@@ -238,7 +238,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
@@ -247,7 +247,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
@@ -256,7 +256,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
@@ -265,7 +265,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
@@ -274,7 +274,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
@@ -283,7 +283,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
@@ -292,7 +292,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
@@ -301,7 +301,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
@@ -310,7 +310,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
@@ -319,7 +319,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
@@ -328,7 +328,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
@@ -337,7 +337,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
@@ -346,9 +346,9 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
]
],
)
def test_PythonFunctionDefinition_exceptions(
name,
@@ -357,7 +357,7 @@ def test_PythonFunctionDefinition_exceptions(
doc,
decorators,
expected_exception,
expected_exception_message
expected_exception_message,
):
with pytest.raises(expected_exception) as exc_info:
PythonClassDefinition(name, args, returns, doc, decorators)
@@ -372,8 +372,7 @@ def test_PythonFunctionDefinition_exceptions(
':\n\tdef __init__(self, value: object) -> None:'
'\n\t\tself._value = value\n\n\t@property\n\tdef'
' value(self) -> object:\n\t\treturn self._value'
)
),
),
PythonClassDefinition(
'Class',
@@ -388,18 +387,18 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
),
PythonFunctionArgument(
'value',
PythonArgumentKind.NORMAL,
None,
'object'
)
'object',
),
],
'None',
None,
[]
[],
),
PythonFunctionDefinition(
'value',
@@ -408,15 +407,15 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
)
None,
),
],
'object',
None,
['property']
)
]
)
['property'],
),
],
),
),
(
ast_node('class Class: ...'),
@@ -425,8 +424,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
None,
[],
[]
)
[],
),
),
(
ast_node('class Class: \'\'\'docstring\'\'\''),
@@ -435,8 +434,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
PythonDocstring('docstring'),
[],
[]
)
[],
),
),
(
ast_node('class Class:\n\tdef __init__(self): ...'),
@@ -453,15 +452,15 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
None,
)
],
None,
None,
[]
)
]
)
[],
),
],
),
),
(
ast_node('class Class:\n\t\'\'\'doc\'\'\'\n\tdef __init__(self): ...'),
@@ -478,15 +477,15 @@ def test_PythonFunctionDefinition_exceptions(
'self',
PythonArgumentKind.NORMAL,
None,
None
)
None,
),
],
None,
None,
[]
)
]
)
[],
),
],
),
),
])
def test_PythonDefinition_from_node(node, expected):
@@ -22,17 +22,17 @@ import pytest
PythonDefinition(
'a',
None,
[]
[],
),
'PythonDefinition(\'a\', None, [])'
'PythonDefinition(\'a\', None, [])',
),
(
PythonDefinition(
'a',
PythonDocstring('Hello, World!'),
[]
[],
),
'PythonDefinition(\'a\', PythonDocstring(\'Hello, World!\'), [])'
'PythonDefinition(\'a\', PythonDocstring(\'Hello, World!\'), [])',
),
])
def test_PythonDefinition_string_representation(definition, expected):
@@ -47,233 +47,233 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
]
],
)
def test_PythonDefinition_exceptions(
name,
doc,
decorators,
expected_exception,
expected_exception_message
expected_exception_message,
):
with pytest.raises(expected_exception) as exc_info:
PythonDefinition(name, doc, decorators)
@@ -285,157 +285,157 @@ def test_PythonDefinition_exceptions(
PythonDefinition(
'a',
None,
[]
[],
),
PythonDefinition(
'a',
None,
[]
[],
),
True
True,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
True
True,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
['a']
['a'],
),
PythonDefinition(
'a',
PythonDocstring('doc'),
['a']
['a'],
),
True
True,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
['a', 'b']
['a', 'b'],
),
PythonDefinition(
'a',
PythonDocstring('doc'),
['a', 'b']
['a', 'b'],
),
True
True,
),
(
PythonDefinition(
'a',
None,
[]
[],
),
PythonDefinition(
'b',
None,
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'a',
None,
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'a',
PythonDocstring('docs'),
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['a']
['a'],
),
PythonDefinition(
'a',
None,
['b']
['b'],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['a']
['a'],
),
PythonDefinition(
'a',
None,
[]
[],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['a']
['a'],
),
PythonDefinition(
'a',
None,
['a', 'b']
['a', 'b'],
),
False
False,
),
(
PythonDefinition(
'a',
None,
['b', 'a']
['b', 'a'],
),
PythonDefinition(
'a',
None,
['a', 'b']
['a', 'b'],
),
False
False,
),
(
PythonDefinition(
'a',
PythonDocstring('doc'),
[]
[],
),
PythonDefinition(
'b',
None,
['a', 'b']
['a', 'b'],
),
False
False,
),
])
def test_PythonDefinition___eq__(definition1, definition2, expected):
@@ -15,7 +15,7 @@
from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition
from src.jcloud_docsgen.core.python.arguments import (
PythonFunctionArgument,
PythonArgumentKind
PythonArgumentKind,
)
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
@@ -29,9 +29,9 @@ import pytest
[],
None,
None,
[]
[],
),
'PythonFunctionDefinition(\'a\', [], None, None, [])'
'PythonFunctionDefinition(\'a\', [], None, None, [])',
),
(
PythonFunctionDefinition(
@@ -39,12 +39,12 @@ import pytest
[],
None,
PythonDocstring('Hello, World!'),
[]
[],
),
(
'PythonFunctionDefinition(\'a\', [], None,'
' PythonDocstring(\'Hello, World!\'), [])'
)
),
),
])
def test_PythonDefinition_string_representation(definition, expected):
@@ -64,7 +64,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier'
'invalid identifier',
),
(
'.',
@@ -73,7 +73,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: .'
'invalid identifier: .',
),
(
'#',
@@ -82,7 +82,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: #'
'invalid identifier: #',
),
(
'1a',
@@ -91,7 +91,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1a'
'invalid identifier: 1a',
),
(
'1_',
@@ -100,7 +100,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1_'
'invalid identifier: 1_',
),
(
'1,',
@@ -109,7 +109,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: 1,'
'invalid identifier: 1,',
),
(
',',
@@ -118,7 +118,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,'
'invalid identifier: ,',
),
(
':',
@@ -127,7 +127,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :'
'invalid identifier: :',
),
(
'-',
@@ -136,7 +136,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -'
'invalid identifier: -',
),
(
';',
@@ -145,7 +145,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;'
'invalid identifier: ;',
),
(
'|',
@@ -154,7 +154,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |'
'invalid identifier: |',
),
(
'<',
@@ -163,7 +163,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <'
'invalid identifier: <',
),
(
'>',
@@ -172,7 +172,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >'
'invalid identifier: >',
),
(
'a,',
@@ -181,7 +181,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a,'
'invalid identifier: a,',
),
(
',a',
@@ -190,7 +190,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ,a'
'invalid identifier: ,a',
),
(
'a:',
@@ -199,7 +199,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a:'
'invalid identifier: a:',
),
(
':a',
@@ -208,7 +208,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: :a'
'invalid identifier: :a',
),
(
'a-',
@@ -217,7 +217,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a-'
'invalid identifier: a-',
),
(
'-a',
@@ -226,7 +226,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: -a'
'invalid identifier: -a',
),
(
'a;',
@@ -235,7 +235,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a;'
'invalid identifier: a;',
),
(
';a',
@@ -244,7 +244,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: ;a'
'invalid identifier: ;a',
),
(
'a|',
@@ -253,7 +253,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a|'
'invalid identifier: a|',
),
(
'|a',
@@ -262,7 +262,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: |a'
'invalid identifier: |a',
),
(
'a<',
@@ -271,7 +271,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a<'
'invalid identifier: a<',
),
(
'<a',
@@ -280,7 +280,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: <a'
'invalid identifier: <a',
),
(
'a>',
@@ -289,7 +289,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: a>'
'invalid identifier: a>',
),
(
'>a',
@@ -298,7 +298,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: >a'
'invalid identifier: >a',
),
(
'class',
@@ -307,7 +307,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: class'
'invalid identifier: class',
),
(
'def',
@@ -316,7 +316,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: def'
'invalid identifier: def',
),
(
'lambda',
@@ -325,7 +325,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: lambda'
'invalid identifier: lambda',
),
(
'None',
@@ -334,7 +334,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: None'
'invalid identifier: None',
),
(
'True',
@@ -343,7 +343,7 @@ def test_PythonDefinition_string_representation(definition, expected):
None,
[],
InvalidPythonIdentifierError,
'invalid identifier: True'
'invalid identifier: True',
),
])
def test_PythonFunctionDefinition_exceptions(
@@ -353,7 +353,7 @@ def test_PythonFunctionDefinition_exceptions(
doc,
decorators,
expected_exception,
expected_exception_message
expected_exception_message,
):
with pytest.raises(expected_exception) as exc_info:
PythonFunctionDefinition(name, args, returns, doc, decorators)
@@ -369,19 +369,19 @@ def test_PythonFunctionDefinition_exceptions(
'a',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
],
'int',
None,
[]
)
[],
),
),
(
ast_node('@decorator\ndef add(a: int, b: int) -> int: return a + b'),
@@ -392,26 +392,26 @@ def test_PythonFunctionDefinition_exceptions(
'a',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
],
'int',
None,
['decorator']
)
['decorator'],
),
),
(
ast_node(
(
'@decorator1\n@decorator2\ndef add(a'
': int, b: int) -> int: return a + b'
)
),
),
PythonFunctionDefinition(
'add',
@@ -420,19 +420,19 @@ def test_PythonFunctionDefinition_exceptions(
'a',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
PythonFunctionArgument(
'b',
PythonArgumentKind.NORMAL,
None,
'int'
'int',
),
],
'int',
None,
['decorator1', 'decorator2']
)
['decorator1', 'decorator2'],
),
),
(
ast_node('def func(): ...'),
@@ -441,8 +441,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
None,
None,
[]
)
[],
),
),
(
ast_node('@decorator\ndef func(): ...'),
@@ -451,8 +451,8 @@ def test_PythonFunctionDefinition_exceptions(
[],
None,
None,
['decorator']
)
['decorator'],
),
),
])
def test_PythonDefinition_from_node(node, expected):