generated from jCloud/repository-template
chore: lint source code using Ruff
This commit is contained in:
35 files changed
+161
-130
No files matched your search
@@ -13,14 +13,15 @@
|
||||
# limitations under the License.
|
||||
|
||||
from __future__ import annotations
|
||||
from typing import Union
|
||||
|
||||
import ast
|
||||
from .arguments import PythonFunctionArgument, PythonASTArgumentsListParser
|
||||
from .docstrings import PythonDocstring
|
||||
import keyword
|
||||
import types
|
||||
|
||||
from ...exceptions import InvalidPythonIdentifierError
|
||||
from ...utils import assert_that_is_instance
|
||||
import types
|
||||
from .arguments import PythonASTArgumentsListParser, PythonFunctionArgument
|
||||
from .docstrings import PythonDocstring
|
||||
|
||||
__all__ = [
|
||||
'PythonDefinition',
|
||||
@@ -30,16 +31,16 @@ __all__ = [
|
||||
]
|
||||
|
||||
|
||||
def _python_docstring(doc: Union[str, None]) -> Union[PythonDocstring, None]:
|
||||
def _python_docstring(doc: str | None) -> PythonDocstring | None:
|
||||
"""
|
||||
Returns the PythonDocstring object if the docstring is a string and
|
||||
not ``None``.
|
||||
|
||||
:param doc: The docstring.
|
||||
:type doc: Union[str, None]
|
||||
:type doc: str | None
|
||||
|
||||
:return: The PythonDocstring object or ``None``.
|
||||
:rtype: Union[PythonDocstring, None]
|
||||
:rtype: PythonDocstring | None
|
||||
"""
|
||||
|
||||
return PythonDocstring(doc) if doc is not None else None
|
||||
@@ -53,7 +54,7 @@ class PythonDefinition:
|
||||
:param name: The name of the definition.
|
||||
:type name: str
|
||||
:param doc: The docstring.
|
||||
:type doc: Union[PythonDocstring, None]
|
||||
:type doc: PythonDocstring | None
|
||||
:param decorators: The definition decorators.
|
||||
:type decorators: list[str]
|
||||
|
||||
@@ -64,7 +65,7 @@ class PythonDefinition:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
doc: Union[PythonDocstring, None],
|
||||
doc: PythonDocstring | None,
|
||||
decorators: list[str],
|
||||
) -> None:
|
||||
if keyword.iskeyword(name) or not name.isidentifier() or not name:
|
||||
@@ -120,9 +121,9 @@ class PythonFunctionDefinition(PythonDefinition):
|
||||
:param args: The arguments.
|
||||
:type args: list[PythonFunctionArgument]
|
||||
:param returns: The return type of the function or class.
|
||||
:type returns: Union[str, None]
|
||||
:type returns: str | None
|
||||
:param doc: The docstring.
|
||||
:type doc: Union[PythonDocstring, None]
|
||||
:type doc: PythonDocstring | None
|
||||
:param decorators: The definition decorators.
|
||||
:type decorators: list[str]
|
||||
|
||||
@@ -134,8 +135,8 @@ class PythonFunctionDefinition(PythonDefinition):
|
||||
self,
|
||||
name: str,
|
||||
args: list[PythonFunctionArgument],
|
||||
returns: Union[str, None],
|
||||
doc: Union[PythonDocstring, None],
|
||||
returns: str | None,
|
||||
doc: PythonDocstring | None,
|
||||
decorators: list[str],
|
||||
) -> None:
|
||||
super().__init__(name, doc, decorators)
|
||||
@@ -179,9 +180,9 @@ class PythonAsyncFunctionDefinition(PythonFunctionDefinition):
|
||||
:param args: The arguments.
|
||||
:type args: list[PythonFunctionArgument]
|
||||
:param returns: The return type of the function or class.
|
||||
:type returns: Union[str, None]
|
||||
:type returns: str | None
|
||||
:param doc: The docstring.
|
||||
:type doc: Union[PythonDocstring, None]
|
||||
:type doc: PythonDocstring | None
|
||||
:param decorators: The definition decorators.
|
||||
:type decorators: list[str]
|
||||
|
||||
@@ -199,7 +200,7 @@ class PythonClassDefinition(PythonDefinition):
|
||||
:param bases: The base classes.
|
||||
:type bases: list[str]
|
||||
:param doc: The docstring.
|
||||
:type doc: Union[PythonDocstring, None]
|
||||
:type doc: PythonDocstring | None
|
||||
:param decorators: The definition decorators.
|
||||
:type decorators: list[str]
|
||||
:param body:
|
||||
@@ -213,7 +214,7 @@ class PythonClassDefinition(PythonDefinition):
|
||||
self,
|
||||
name: str,
|
||||
bases: list[str],
|
||||
doc: Union[PythonDocstring, None],
|
||||
doc: PythonDocstring | None,
|
||||
decorators: list[str],
|
||||
body: list[PythonDefinition],
|
||||
) -> None:
|
||||
|
||||
Reference in new issue
Block a user