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,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .cli.cli import main
|
from .cli.cli import main
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from . import cli
|
from . import cli, languages
|
||||||
from . import languages
|
|
||||||
from .cli import main
|
from .cli import main
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ The command line interface
|
|||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from .languages.python import VALID_SECTIONS as VALID_PYTHON_SECTIONS
|
from .languages.python import VALID_SECTIONS as VALID_PYTHON_SECTIONS
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
@@ -169,7 +170,7 @@ def main(argv=None) -> int:
|
|||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
# TODO: add a custom exception class to clearify that a project
|
# TODO: add a custom exception class to clearify that a project
|
||||||
# parsing syntax error is meant.
|
# parsing syntax error is meant.
|
||||||
return error(f'syntax error in project source code')
|
return error('syntax error in project source code')
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
return 130
|
return 130
|
||||||
except BrokenPipeError:
|
except BrokenPipeError:
|
||||||
|
|||||||
@@ -13,11 +13,11 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
from ...core.python import (
|
from ...core.python import (
|
||||||
PythonDefinitionDocumentationIncludeSections,
|
PythonDefinitionDocumentationIncludeSections,
|
||||||
PythonDocumentationGenerator,
|
PythonDocumentationGenerator,
|
||||||
)
|
)
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'VALID_SECTIONS',
|
'VALID_SECTIONS',
|
||||||
@@ -31,7 +31,7 @@ VALID_SECTIONS = list(
|
|||||||
|
|
||||||
|
|
||||||
def parse_sections_list(
|
def parse_sections_list(
|
||||||
include_sections: Optional[list[str]] = None,
|
include_sections: list[str] | None = None,
|
||||||
exclude_sections: list[str] = [],
|
exclude_sections: list[str] = [],
|
||||||
) -> PythonDefinitionDocumentationIncludeSections:
|
) -> PythonDefinitionDocumentationIncludeSections:
|
||||||
"""
|
"""
|
||||||
@@ -41,7 +41,7 @@ def parse_sections_list(
|
|||||||
the section name.
|
the section name.
|
||||||
|
|
||||||
:param include_sections: The list of sections to be included.
|
:param include_sections: The list of sections to be included.
|
||||||
:type include_sections: Optional[list[str]]
|
:type include_sections: list[str] | None
|
||||||
:param exclude_sections: The list of sections to be excluded.
|
:param exclude_sections: The list of sections to be excluded.
|
||||||
:type exclude_sections: list[str]
|
:type exclude_sections: list[str]
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ def generate(
|
|||||||
project_directory: pathlib.Path,
|
project_directory: pathlib.Path,
|
||||||
output_directory: pathlib.Path,
|
output_directory: pathlib.Path,
|
||||||
*,
|
*,
|
||||||
include_sections: Optional[list[str]] = None,
|
include_sections: list[str] | None = None,
|
||||||
exclude_sections: list[str] = [],
|
exclude_sections: list[str] = [],
|
||||||
allow_html: bool = False,
|
allow_html: bool = False,
|
||||||
allow_tables: bool = False,
|
allow_tables: bool = False,
|
||||||
@@ -124,7 +124,7 @@ def generate(
|
|||||||
:type output_directory: pathlib.Path
|
:type output_directory: pathlib.Path
|
||||||
:param include_sections: The sections to be included in the
|
:param include_sections: The sections to be included in the
|
||||||
documentation.
|
documentation.
|
||||||
:type include_sections: Optional[list[str]]
|
:type include_sections: list[str] | None
|
||||||
:param exclude_sections: The sections to be excluded in the
|
:param exclude_sections: The sections to be excluded in the
|
||||||
documentation.
|
documentation.
|
||||||
:type exclude_sections: list[str]
|
:type exclude_sections: list[str]
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from . import namespaces
|
||||||
from ._core import *
|
from ._core import *
|
||||||
from ._core import __all__ as _core__all__
|
from ._core import __all__ as _core__all__
|
||||||
from . import namespaces
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
*_core__all__,
|
*_core__all__,
|
||||||
|
|||||||
@@ -13,25 +13,26 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from ...utils import non_empty_str, get_relative_path_segments
|
|
||||||
from ...exceptions import PythonArgumentStructureError, InvalidNamespaceError
|
import ast
|
||||||
from .namespaces import PythonModuleNamespace, PythonPackageNamespace
|
import pathlib
|
||||||
|
from collections.abc import Iterator
|
||||||
|
from dataclasses import dataclass
|
||||||
|
from typing import TypeAlias
|
||||||
|
|
||||||
|
import docstring_parser
|
||||||
|
|
||||||
|
from ...exceptions import InvalidNamespaceError, PythonArgumentStructureError
|
||||||
|
from ...utils import get_relative_path_segments, non_empty_str
|
||||||
|
from .arguments import PythonArgumentKind, PythonFunctionArgument
|
||||||
from .definitions import (
|
from .definitions import (
|
||||||
PythonAsyncFunctionDefinition,
|
PythonAsyncFunctionDefinition,
|
||||||
PythonClassDefinition,
|
PythonClassDefinition,
|
||||||
PythonDefinition,
|
PythonDefinition,
|
||||||
PythonFunctionDefinition,
|
PythonFunctionDefinition,
|
||||||
)
|
)
|
||||||
from .arguments import PythonArgumentKind, PythonFunctionArgument
|
|
||||||
from .docstrings import PythonDocstring
|
from .docstrings import PythonDocstring
|
||||||
from collections.abc import Iterator
|
from .namespaces import PythonModuleNamespace, PythonPackageNamespace
|
||||||
from typing import TypeAlias, Union
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from enum import Enum
|
|
||||||
import docstring_parser
|
|
||||||
import pathlib
|
|
||||||
import ast
|
|
||||||
import types
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'PythonDefinitionDocumentationIncludeSections',
|
'PythonDefinitionDocumentationIncludeSections',
|
||||||
@@ -63,9 +64,9 @@ def _collect_definitions(tree_or_node) -> Iterator[PythonDefinition]:
|
|||||||
_Arguments: TypeAlias = tuple[
|
_Arguments: TypeAlias = tuple[
|
||||||
list[PythonFunctionArgument],
|
list[PythonFunctionArgument],
|
||||||
list[PythonFunctionArgument],
|
list[PythonFunctionArgument],
|
||||||
Union[PythonFunctionArgument, None],
|
PythonFunctionArgument | None,
|
||||||
list[PythonFunctionArgument],
|
list[PythonFunctionArgument],
|
||||||
Union[PythonFunctionArgument, None],
|
PythonFunctionArgument | None,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -298,12 +299,12 @@ def _markdown_table(
|
|||||||
return table.strip()
|
return table.strip()
|
||||||
|
|
||||||
|
|
||||||
def _is_docstring(docstring: Union[str, PythonDocstring, None]) -> bool:
|
def _is_docstring(docstring: str | PythonDocstring | None) -> bool:
|
||||||
"""
|
"""
|
||||||
Checks whether the docstring is a docstring or an empty docstring.
|
Checks whether the docstring is a docstring or an empty docstring.
|
||||||
|
|
||||||
:param docstring: The docstring.
|
:param docstring: The docstring.
|
||||||
:type docstring: Union[str, PythonDocstring, None]
|
:type docstring: str | PythonDocstring | None
|
||||||
|
|
||||||
:return: Whether there is a docstring.
|
:return: Whether there is a docstring.
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
@@ -320,8 +321,8 @@ def _is_docstring(docstring: Union[str, PythonDocstring, None]) -> bool:
|
|||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class _FunctionParamInfo:
|
class _FunctionParamInfo:
|
||||||
annotation: Union[str, None]
|
annotation: str | None
|
||||||
description: Union[str, None]
|
description: str | None
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@@ -908,7 +909,7 @@ class PythonModuleDocumentationGenerator:
|
|||||||
:param src_directory: The directory of the source code. It is
|
:param src_directory: The directory of the source code. It is
|
||||||
optional and only used for making the module
|
optional and only used for making the module
|
||||||
identifiers in the documentation relative.
|
identifiers in the documentation relative.
|
||||||
:type src_directory: Union[pathlib.Path, None]
|
:type src_directory: pathlib.Path | None
|
||||||
:param include_sections: The sections that will be included.
|
:param include_sections: The sections that will be included.
|
||||||
:type include_sections: PythonDefinitionDocumentationIncludeSections
|
:type include_sections: PythonDefinitionDocumentationIncludeSections
|
||||||
:param kwargs: The options for ``PythonDefinitionDocumentationGenerator``.
|
:param kwargs: The options for ``PythonDefinitionDocumentationGenerator``.
|
||||||
@@ -917,7 +918,7 @@ class PythonModuleDocumentationGenerator:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
module_path: pathlib.Path,
|
module_path: pathlib.Path,
|
||||||
src_directory: Union[pathlib.Path, None] = None,
|
src_directory: pathlib.Path | None = None,
|
||||||
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
include_sections: PythonDefinitionDocumentationIncludeSections = (
|
||||||
PythonDefinitionDocumentationIncludeSections()
|
PythonDefinitionDocumentationIncludeSections()
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -13,17 +13,18 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from enum import Enum
|
|
||||||
from typing import Union
|
|
||||||
import ast
|
import ast
|
||||||
from ...utils import assert_that_is_instance
|
import keyword
|
||||||
|
import types
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
from ...exceptions import (
|
from ...exceptions import (
|
||||||
InvalidPythonAnnotationError,
|
InvalidPythonAnnotationError,
|
||||||
InvalidPythonIdentifierError,
|
InvalidPythonIdentifierError,
|
||||||
PythonArgumentStructureError,
|
PythonArgumentStructureError,
|
||||||
)
|
)
|
||||||
import keyword
|
from ...utils import assert_that_is_instance
|
||||||
import types
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'PythonArgumentKind',
|
'PythonArgumentKind',
|
||||||
@@ -49,17 +50,17 @@ class PythonFunctionArgument:
|
|||||||
:param kind: The kind of the argument.
|
:param kind: The kind of the argument.
|
||||||
:type kind: ArgumentKind
|
:type kind: ArgumentKind
|
||||||
:param default: The default value of the argument.
|
:param default: The default value of the argument.
|
||||||
:type default: Union[str, None]
|
:type default: str | None
|
||||||
:param annotation: The type annotation of the argument.
|
:param annotation: The type annotation of the argument.
|
||||||
:type annotation: Union[str, None]
|
:type annotation: str | None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
kind: PythonArgumentKind,
|
kind: PythonArgumentKind,
|
||||||
default: Union[str, None],
|
default: str | None,
|
||||||
annotation: Union[str, None],
|
annotation: str | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
assert_that_is_instance(name, str)
|
assert_that_is_instance(name, str)
|
||||||
assert_that_is_instance(kind, PythonArgumentKind)
|
assert_that_is_instance(kind, PythonArgumentKind)
|
||||||
|
|||||||
@@ -13,14 +13,15 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
from typing import Union
|
|
||||||
import ast
|
import ast
|
||||||
from .arguments import PythonFunctionArgument, PythonASTArgumentsListParser
|
|
||||||
from .docstrings import PythonDocstring
|
|
||||||
import keyword
|
import keyword
|
||||||
|
import types
|
||||||
|
|
||||||
from ...exceptions import InvalidPythonIdentifierError
|
from ...exceptions import InvalidPythonIdentifierError
|
||||||
from ...utils import assert_that_is_instance
|
from ...utils import assert_that_is_instance
|
||||||
import types
|
from .arguments import PythonASTArgumentsListParser, PythonFunctionArgument
|
||||||
|
from .docstrings import PythonDocstring
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'PythonDefinition',
|
'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
|
Returns the PythonDocstring object if the docstring is a string and
|
||||||
not ``None``.
|
not ``None``.
|
||||||
|
|
||||||
:param doc: The docstring.
|
:param doc: The docstring.
|
||||||
:type doc: Union[str, None]
|
:type doc: str | None
|
||||||
|
|
||||||
:return: The PythonDocstring object or ``None``.
|
:return: The PythonDocstring object or ``None``.
|
||||||
:rtype: Union[PythonDocstring, None]
|
:rtype: PythonDocstring | None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return PythonDocstring(doc) if doc is not None else None
|
return PythonDocstring(doc) if doc is not None else None
|
||||||
@@ -53,7 +54,7 @@ class PythonDefinition:
|
|||||||
:param name: The name of the definition.
|
:param name: The name of the definition.
|
||||||
:type name: str
|
:type name: str
|
||||||
:param doc: The docstring.
|
:param doc: The docstring.
|
||||||
:type doc: Union[PythonDocstring, None]
|
:type doc: PythonDocstring | None
|
||||||
:param decorators: The definition decorators.
|
:param decorators: The definition decorators.
|
||||||
:type decorators: list[str]
|
:type decorators: list[str]
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ class PythonDefinition:
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
doc: Union[PythonDocstring, None],
|
doc: PythonDocstring | None,
|
||||||
decorators: list[str],
|
decorators: list[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
if keyword.iskeyword(name) or not name.isidentifier() or not name:
|
if keyword.iskeyword(name) or not name.isidentifier() or not name:
|
||||||
@@ -120,9 +121,9 @@ class PythonFunctionDefinition(PythonDefinition):
|
|||||||
:param args: The arguments.
|
:param args: The arguments.
|
||||||
:type args: list[PythonFunctionArgument]
|
:type args: list[PythonFunctionArgument]
|
||||||
:param returns: The return type of the function or class.
|
:param returns: The return type of the function or class.
|
||||||
:type returns: Union[str, None]
|
:type returns: str | None
|
||||||
:param doc: The docstring.
|
:param doc: The docstring.
|
||||||
:type doc: Union[PythonDocstring, None]
|
:type doc: PythonDocstring | None
|
||||||
:param decorators: The definition decorators.
|
:param decorators: The definition decorators.
|
||||||
:type decorators: list[str]
|
:type decorators: list[str]
|
||||||
|
|
||||||
@@ -134,8 +135,8 @@ class PythonFunctionDefinition(PythonDefinition):
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
args: list[PythonFunctionArgument],
|
args: list[PythonFunctionArgument],
|
||||||
returns: Union[str, None],
|
returns: str | None,
|
||||||
doc: Union[PythonDocstring, None],
|
doc: PythonDocstring | None,
|
||||||
decorators: list[str],
|
decorators: list[str],
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(name, doc, decorators)
|
super().__init__(name, doc, decorators)
|
||||||
@@ -179,9 +180,9 @@ class PythonAsyncFunctionDefinition(PythonFunctionDefinition):
|
|||||||
:param args: The arguments.
|
:param args: The arguments.
|
||||||
:type args: list[PythonFunctionArgument]
|
:type args: list[PythonFunctionArgument]
|
||||||
:param returns: The return type of the function or class.
|
:param returns: The return type of the function or class.
|
||||||
:type returns: Union[str, None]
|
:type returns: str | None
|
||||||
:param doc: The docstring.
|
:param doc: The docstring.
|
||||||
:type doc: Union[PythonDocstring, None]
|
:type doc: PythonDocstring | None
|
||||||
:param decorators: The definition decorators.
|
:param decorators: The definition decorators.
|
||||||
:type decorators: list[str]
|
:type decorators: list[str]
|
||||||
|
|
||||||
@@ -199,7 +200,7 @@ class PythonClassDefinition(PythonDefinition):
|
|||||||
:param bases: The base classes.
|
:param bases: The base classes.
|
||||||
:type bases: list[str]
|
:type bases: list[str]
|
||||||
:param doc: The docstring.
|
:param doc: The docstring.
|
||||||
:type doc: Union[PythonDocstring, None]
|
:type doc: PythonDocstring | None
|
||||||
:param decorators: The definition decorators.
|
:param decorators: The definition decorators.
|
||||||
:type decorators: list[str]
|
:type decorators: list[str]
|
||||||
:param body:
|
:param body:
|
||||||
@@ -213,7 +214,7 @@ class PythonClassDefinition(PythonDefinition):
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
bases: list[str],
|
bases: list[str],
|
||||||
doc: Union[PythonDocstring, None],
|
doc: PythonDocstring | None,
|
||||||
decorators: list[str],
|
decorators: list[str],
|
||||||
body: list[PythonDefinition],
|
body: list[PythonDefinition],
|
||||||
) -> None:
|
) -> None:
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from enum import Enum
|
|
||||||
import docstring_parser
|
import docstring_parser
|
||||||
|
|
||||||
__all__ = ['PythonDocstring']
|
__all__ = ['PythonDocstring']
|
||||||
|
|||||||
@@ -13,13 +13,15 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TypeAlias, Union
|
||||||
|
|
||||||
from ...exceptions import (
|
from ...exceptions import (
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
NamespaceNotFoundError,
|
|
||||||
NamespaceExistsError,
|
NamespaceExistsError,
|
||||||
|
NamespaceNotFoundError,
|
||||||
)
|
)
|
||||||
from ...utils import assert_that_is_instance
|
from ...utils import assert_that_is_instance
|
||||||
from typing import Union, TypeAlias, Dict, List
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'PythonNamespace',
|
'PythonNamespace',
|
||||||
@@ -51,7 +53,7 @@ class PythonNamespace:
|
|||||||
return f'{type(self).__name__}({self.name!r})'
|
return f'{type(self).__name__}({self.name!r})'
|
||||||
|
|
||||||
|
|
||||||
PythonPackageNamespaceDictType: TypeAlias = Dict[
|
PythonPackageNamespaceDictType: TypeAlias = dict[
|
||||||
str,
|
str,
|
||||||
Union[
|
Union[
|
||||||
str,
|
str,
|
||||||
@@ -73,7 +75,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
sub_namespaces: List[PythonNamespace],
|
sub_namespaces: list[PythonNamespace],
|
||||||
) -> None:
|
) -> None:
|
||||||
assert_that_is_instance(sub_namespaces, list)
|
assert_that_is_instance(sub_namespaces, list)
|
||||||
|
|
||||||
@@ -81,7 +83,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
|
|
||||||
self._sub_namespaces = sub_namespaces
|
self._sub_namespaces = sub_namespaces
|
||||||
|
|
||||||
def namespace(self, sub_namespaces: List[str]) -> PythonNamespace:
|
def namespace(self, sub_namespaces: list[str]) -> PythonNamespace:
|
||||||
"""
|
"""
|
||||||
Returns the namespace object with a specific identifier, such as
|
Returns the namespace object with a specific identifier, such as
|
||||||
``['package', 'subpackage', 'module']``.
|
``['package', 'subpackage', 'module']``.
|
||||||
@@ -205,7 +207,7 @@ class PythonPackageNamespace(PythonNamespace):
|
|||||||
self._sub_namespaces.append(namespace)
|
self._sub_namespaces.append(namespace)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sub_namespaces(self) -> List[PythonNamespace]:
|
def sub_namespaces(self) -> list[PythonNamespace]:
|
||||||
return self._sub_namespaces
|
return self._sub_namespaces
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
The utilities for jcloud_docsgen
|
The utilities for jcloud_docsgen
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import pathlib
|
|
||||||
import os
|
|
||||||
import errno
|
import errno
|
||||||
from typing import Union
|
import os
|
||||||
|
import pathlib
|
||||||
import types
|
import types
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from warnings import deprecated
|
from warnings import deprecated
|
||||||
@@ -152,11 +152,7 @@ def _list_type_names(types: list[type]) -> list[str]:
|
|||||||
|
|
||||||
def assert_that_is_instance(
|
def assert_that_is_instance(
|
||||||
obj: object,
|
obj: object,
|
||||||
class_or_tuple: Union[
|
class_or_tuple: type | types.UnionType | tuple[type, ...],
|
||||||
type,
|
|
||||||
types.UnionType,
|
|
||||||
tuple[type, ...],
|
|
||||||
],
|
|
||||||
) -> None:
|
) -> None:
|
||||||
if not isinstance(class_or_tuple, Union[type, types.UnionType, tuple]):
|
if not isinstance(class_or_tuple, Union[type, types.UnionType, tuple]):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
@@ -185,7 +181,7 @@ def assert_that_is_instance(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def non_empty_str(value: Union[str, None]) -> Union[str, None]:
|
def non_empty_str(value: str | None) -> str | None:
|
||||||
"""
|
"""
|
||||||
Returns the value or ``None``.
|
Returns the value or ``None``.
|
||||||
|
|
||||||
@@ -195,10 +191,10 @@ def non_empty_str(value: Union[str, None]) -> Union[str, None]:
|
|||||||
of spaces, it is also considered empty.
|
of spaces, it is also considered empty.
|
||||||
|
|
||||||
:param value: The value.
|
:param value: The value.
|
||||||
:type value: Union[str, None]
|
:type value: str | None
|
||||||
|
|
||||||
:return: The value or ``None``.
|
:return: The value or ``None``.
|
||||||
:rtype: Union[str, None]
|
:rtype: str | None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from jcloud_docsgen.cli.cli import create_argument_parser
|
from jcloud_docsgen.cli.cli import create_argument_parser
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,11 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from jcloud_docsgen.cli.cli import create_argument_parser, main as cli_main
|
|
||||||
|
from jcloud_docsgen.cli.cli import create_argument_parser
|
||||||
|
from jcloud_docsgen.cli.cli import main as cli_main
|
||||||
from jcloud_docsgen.cli.languages.python import parse_sections_list
|
from jcloud_docsgen.cli.languages.python import parse_sections_list
|
||||||
from jcloud_docsgen.core.python import (
|
from jcloud_docsgen.core.python import (
|
||||||
PythonDefinitionDocumentationIncludeSections,
|
PythonDefinitionDocumentationIncludeSections,
|
||||||
|
|||||||
@@ -12,21 +12,22 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import (
|
from src.jcloud_docsgen.core.python._core import (
|
||||||
PythonDefinitionDocumentationGenerator,
|
PythonDefinitionDocumentationGenerator,
|
||||||
PythonDefinitionDocumentationIncludeSections,
|
PythonDefinitionDocumentationIncludeSections,
|
||||||
)
|
)
|
||||||
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
|
)
|
||||||
from src.jcloud_docsgen.core.python.definitions import (
|
from src.jcloud_docsgen.core.python.definitions import (
|
||||||
PythonFunctionDefinition,
|
|
||||||
PythonAsyncFunctionDefinition,
|
PythonAsyncFunctionDefinition,
|
||||||
PythonClassDefinition,
|
PythonClassDefinition,
|
||||||
)
|
PythonFunctionDefinition,
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
def _signature_section(signature: str) -> str:
|
def _signature_section(signature: str) -> str:
|
||||||
|
|||||||
@@ -12,13 +12,15 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python import PythonDocumentationGenerator
|
from src.jcloud_docsgen.core.python import PythonDocumentationGenerator
|
||||||
from src.jcloud_docsgen.core.python.namespaces import (
|
from src.jcloud_docsgen.core.python.namespaces import (
|
||||||
PythonModuleNamespace,
|
PythonModuleNamespace,
|
||||||
PythonPackageNamespace,
|
PythonPackageNamespace,
|
||||||
)
|
)
|
||||||
import pytest
|
|
||||||
import pathlib
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python import PythonModuleDocumentationGenerator
|
from src.jcloud_docsgen.core.python import PythonModuleDocumentationGenerator
|
||||||
from src.jcloud_docsgen.exceptions import InvalidNamespaceError
|
from src.jcloud_docsgen.exceptions import InvalidNamespaceError
|
||||||
import pathlib
|
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _argument_kind_human_readable
|
from src.jcloud_docsgen.core.python._core import _argument_kind_human_readable
|
||||||
from src.jcloud_docsgen.core.python.arguments import PythonArgumentKind
|
from src.jcloud_docsgen.core.python.arguments import PythonArgumentKind
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,18 +12,20 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import ast
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _collect_definitions
|
from src.jcloud_docsgen.core.python._core import _collect_definitions
|
||||||
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
|
)
|
||||||
from src.jcloud_docsgen.core.python.definitions import (
|
from src.jcloud_docsgen.core.python.definitions import (
|
||||||
PythonClassDefinition,
|
PythonClassDefinition,
|
||||||
PythonFunctionDefinition,
|
PythonFunctionDefinition,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
|
||||||
)
|
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
import pytest
|
|
||||||
import ast
|
|
||||||
|
|
||||||
|
|
||||||
def module(source_code: str) -> ast.Module:
|
def module(source_code: str) -> ast.Module:
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _fit_row_length
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.core.python._core import _fit_row_length
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'expected_length,row,expected',
|
'expected_length,row,expected',
|
||||||
|
|||||||
@@ -12,16 +12,17 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import docstring_parser
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import (
|
from src.jcloud_docsgen.core.python._core import (
|
||||||
_function_params_info,
|
_function_params_info,
|
||||||
_FunctionParamInfo,
|
_FunctionParamInfo,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
)
|
)
|
||||||
import pytest
|
|
||||||
import docstring_parser
|
|
||||||
|
|
||||||
|
|
||||||
def docstring_args_list(
|
def docstring_args_list(
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _markdown_table
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.core.python._core import _markdown_table
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -12,12 +12,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python._core import _signature_argument_list
|
from src.jcloud_docsgen.core.python._core import _signature_argument_list
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
)
|
)
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,13 +12,15 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import ast
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
|
PythonArgumentKind,
|
||||||
PythonASTArgumentsListParser,
|
PythonASTArgumentsListParser,
|
||||||
PythonFunctionArgument,
|
PythonFunctionArgument,
|
||||||
PythonArgumentKind,
|
|
||||||
)
|
)
|
||||||
import pytest
|
|
||||||
import ast
|
|
||||||
|
|
||||||
|
|
||||||
def argument_list(argument_list: str) -> ast.arguments:
|
def argument_list(argument_list: str) -> ast.arguments:
|
||||||
|
|||||||
@@ -12,16 +12,17 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.exceptions import (
|
from src.jcloud_docsgen.exceptions import (
|
||||||
InvalidPythonIdentifierError,
|
|
||||||
InvalidPythonAnnotationError,
|
InvalidPythonAnnotationError,
|
||||||
|
InvalidPythonIdentifierError,
|
||||||
PythonArgumentStructureError,
|
PythonArgumentStructureError,
|
||||||
)
|
)
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,18 +12,19 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.definitions import (
|
import pytest
|
||||||
PythonFunctionDefinition,
|
|
||||||
PythonClassDefinition,
|
|
||||||
)
|
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
|
)
|
||||||
|
from src.jcloud_docsgen.core.python.definitions import (
|
||||||
|
PythonClassDefinition,
|
||||||
|
PythonFunctionDefinition,
|
||||||
)
|
)
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
||||||
from tests.utils.ast_node import ast_node
|
from tests.utils.ast_node import ast_node
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.definitions import PythonDefinition
|
from src.jcloud_docsgen.core.python.definitions import PythonDefinition
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,15 +12,16 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition
|
import pytest
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.arguments import (
|
from src.jcloud_docsgen.core.python.arguments import (
|
||||||
PythonFunctionArgument,
|
|
||||||
PythonArgumentKind,
|
PythonArgumentKind,
|
||||||
|
PythonFunctionArgument,
|
||||||
)
|
)
|
||||||
|
from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition
|
||||||
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
from src.jcloud_docsgen.core.python.docstrings import PythonDocstring
|
||||||
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError
|
||||||
from tests.utils.ast_node import ast_node
|
from tests.utils.ast_node import ast_node
|
||||||
import pytest
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.namespaces import PythonModuleNamespace
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.core.python.namespaces import PythonModuleNamespace
|
||||||
|
|
||||||
|
|
||||||
class StrSubclass(str): ...
|
class StrSubclass(str): ...
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.namespaces import PythonNamespace
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.core.python.namespaces import PythonNamespace
|
||||||
|
|
||||||
|
|
||||||
class StrSubclass(str): ...
|
class StrSubclass(str): ...
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,15 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.core.python.namespaces import (
|
|
||||||
PythonPackageNamespace,
|
|
||||||
PythonModuleNamespace,
|
|
||||||
)
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.core.python.namespaces import (
|
||||||
|
PythonModuleNamespace,
|
||||||
|
PythonPackageNamespace,
|
||||||
|
)
|
||||||
from src.jcloud_docsgen.exceptions import (
|
from src.jcloud_docsgen.exceptions import (
|
||||||
NamespaceNotFoundError,
|
|
||||||
InvalidNamespaceError,
|
InvalidNamespaceError,
|
||||||
|
NamespaceNotFoundError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.utils import assert_that_is_instance
|
|
||||||
import pytest
|
|
||||||
import types
|
import types
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.utils import assert_that_is_instance
|
||||||
|
|
||||||
|
|
||||||
class TestType: ...
|
class TestType: ...
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.utils import get_relative_path_segments
|
|
||||||
import pytest
|
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.utils import get_relative_path_segments
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'path,root,expected',
|
'path,root,expected',
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.utils import human_readable_list
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.utils import human_readable_list
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'ls,final_separator,quotation_mark,expected',
|
'ls,final_separator,quotation_mark,expected',
|
||||||
|
|||||||
@@ -12,9 +12,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from src.jcloud_docsgen.utils import non_empty_str
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from src.jcloud_docsgen.utils import non_empty_str
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
'value,expected',
|
'value,expected',
|
||||||
|
|||||||
@@ -12,13 +12,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from typing import Union
|
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
__all__ = ['ast_node']
|
__all__ = ['ast_node']
|
||||||
|
|
||||||
|
|
||||||
def ast_node(statement: str) -> Union[ast.stmt, None]:
|
def ast_node(statement: str) -> ast.stmt | None:
|
||||||
"""
|
"""
|
||||||
Returns an AST node from the statement.
|
Returns an AST node from the statement.
|
||||||
|
|
||||||
@@ -26,7 +25,7 @@ def ast_node(statement: str) -> Union[ast.stmt, None]:
|
|||||||
:type statement: str
|
:type statement: str
|
||||||
|
|
||||||
:return: The node.
|
:return: The node.
|
||||||
:rtype: Union[ast.stmt, None]
|
:rtype: ast.stmt | None
|
||||||
"""
|
"""
|
||||||
|
|
||||||
body = ast.parse(statement).body
|
body = ast.parse(statement).body
|
||||||
|
|||||||
Reference in new issue
Block a user