generated from jCloud/repository-template
style: ensure trailing commas in multi-line statements
This commit is contained in:
30 files changed
+1778
-1774
No files matched your search
@@ -20,7 +20,7 @@ from ...utils import assert_that_is_instance
|
||||
from ...exceptions import (
|
||||
InvalidPythonAnnotationError,
|
||||
InvalidPythonIdentifierError,
|
||||
PythonArgumentStructureError
|
||||
PythonArgumentStructureError,
|
||||
)
|
||||
import keyword
|
||||
import types
|
||||
@@ -28,7 +28,7 @@ import types
|
||||
__all__ = [
|
||||
'PythonArgumentKind',
|
||||
'PythonFunctionArgument',
|
||||
'PythonASTArgumentsListParser'
|
||||
'PythonASTArgumentsListParser',
|
||||
]
|
||||
|
||||
class PythonArgumentKind(Enum):
|
||||
@@ -57,7 +57,7 @@ class PythonFunctionArgument:
|
||||
name: str,
|
||||
kind: PythonArgumentKind,
|
||||
default: Union[str, None],
|
||||
annotation: Union[str, None]
|
||||
annotation: Union[str, None],
|
||||
) -> None:
|
||||
assert_that_is_instance(name, str)
|
||||
assert_that_is_instance(kind, PythonArgumentKind)
|
||||
@@ -68,7 +68,7 @@ class PythonFunctionArgument:
|
||||
if not name or not name.isidentifier() or keyword.iskeyword(name):
|
||||
raise InvalidPythonIdentifierError(
|
||||
'invalid identifier',
|
||||
identifier = name
|
||||
identifier = name,
|
||||
)
|
||||
|
||||
# check whether the annotation is a valid annotation
|
||||
@@ -77,7 +77,7 @@ class PythonFunctionArgument:
|
||||
if annotation is not None and not annotation:
|
||||
raise InvalidPythonAnnotationError(
|
||||
'invalid annotation',
|
||||
annotation = annotation
|
||||
annotation = annotation,
|
||||
)
|
||||
|
||||
self.name = name
|
||||
@@ -87,11 +87,11 @@ class PythonFunctionArgument:
|
||||
|
||||
if self.kind in (
|
||||
PythonArgumentKind.VARARG,
|
||||
PythonArgumentKind.KWARGS
|
||||
PythonArgumentKind.KWARGS,
|
||||
) and self.default is not None:
|
||||
raise PythonArgumentStructureError(
|
||||
'* or ** arguments cannot have default values',
|
||||
definition = self.signature_repr()
|
||||
definition = self.signature_repr(),
|
||||
)
|
||||
|
||||
def __eq__(self, value: PythonFunctionArgument) -> bool:
|
||||
@@ -109,7 +109,7 @@ class PythonFunctionArgument:
|
||||
self.name,
|
||||
self.kind,
|
||||
self.default,
|
||||
self.annotation
|
||||
self.annotation,
|
||||
))
|
||||
|
||||
def signature_repr(self) -> str:
|
||||
@@ -192,8 +192,8 @@ class PythonASTArgumentsListParser:
|
||||
arg.arg,
|
||||
PythonArgumentKind.POSITIONAL_ONLY,
|
||||
defaults[i],
|
||||
None
|
||||
)
|
||||
None,
|
||||
),
|
||||
)
|
||||
else:
|
||||
arguments.append(
|
||||
@@ -201,7 +201,9 @@ class PythonASTArgumentsListParser:
|
||||
arg.arg,
|
||||
PythonArgumentKind.POSITIONAL_ONLY,
|
||||
defaults[i],
|
||||
ast.unparse(arg.annotation)))
|
||||
ast.unparse(arg.annotation),
|
||||
),
|
||||
)
|
||||
i += 1
|
||||
for arg in self.ast_arguments_list.args:
|
||||
if arg.annotation is None:
|
||||
@@ -210,8 +212,8 @@ class PythonASTArgumentsListParser:
|
||||
arg.arg,
|
||||
PythonArgumentKind.NORMAL,
|
||||
defaults[i],
|
||||
None
|
||||
)
|
||||
None,
|
||||
),
|
||||
)
|
||||
else:
|
||||
arguments.append(
|
||||
@@ -219,8 +221,8 @@ class PythonASTArgumentsListParser:
|
||||
arg.arg,
|
||||
PythonArgumentKind.NORMAL,
|
||||
defaults[i],
|
||||
ast.unparse(arg.annotation)
|
||||
)
|
||||
ast.unparse(arg.annotation),
|
||||
),
|
||||
)
|
||||
i += 1
|
||||
if self.ast_arguments_list.vararg is not None:
|
||||
@@ -230,8 +232,8 @@ class PythonASTArgumentsListParser:
|
||||
self.ast_arguments_list.vararg.arg,
|
||||
PythonArgumentKind.VARARG,
|
||||
None,
|
||||
None
|
||||
)
|
||||
None,
|
||||
),
|
||||
)
|
||||
else:
|
||||
arguments.append(
|
||||
@@ -239,8 +241,8 @@ class PythonASTArgumentsListParser:
|
||||
self.ast_arguments_list.vararg.arg,
|
||||
PythonArgumentKind.VARARG,
|
||||
None,
|
||||
ast.unparse(self.ast_arguments_list.vararg.annotation)
|
||||
)
|
||||
ast.unparse(self.ast_arguments_list.vararg.annotation),
|
||||
),
|
||||
)
|
||||
for arg in self.ast_arguments_list.kwonlyargs:
|
||||
if arg.annotation is None:
|
||||
@@ -249,8 +251,8 @@ class PythonASTArgumentsListParser:
|
||||
arg.arg,
|
||||
PythonArgumentKind.KEYWORD_ONLY,
|
||||
defaults[i],
|
||||
None
|
||||
)
|
||||
None,
|
||||
),
|
||||
)
|
||||
else:
|
||||
arguments.append(
|
||||
@@ -258,8 +260,8 @@ class PythonASTArgumentsListParser:
|
||||
arg.arg,
|
||||
PythonArgumentKind.KEYWORD_ONLY,
|
||||
defaults[i],
|
||||
ast.unparse(arg.annotation)
|
||||
)
|
||||
ast.unparse(arg.annotation),
|
||||
),
|
||||
)
|
||||
i += 1
|
||||
if self.ast_arguments_list.kwarg is not None:
|
||||
@@ -269,8 +271,8 @@ class PythonASTArgumentsListParser:
|
||||
self.ast_arguments_list.kwarg.arg,
|
||||
PythonArgumentKind.KWARGS,
|
||||
None,
|
||||
None
|
||||
)
|
||||
None,
|
||||
),
|
||||
)
|
||||
else:
|
||||
arguments.append(
|
||||
@@ -278,8 +280,8 @@ class PythonASTArgumentsListParser:
|
||||
self.ast_arguments_list.kwarg.arg,
|
||||
PythonArgumentKind.KWARGS,
|
||||
None,
|
||||
ast.unparse(self.ast_arguments_list.kwarg.annotation)
|
||||
)
|
||||
ast.unparse(self.ast_arguments_list.kwarg.annotation),
|
||||
),
|
||||
)
|
||||
|
||||
return arguments
|
||||
Reference in new issue
Block a user