diff --git a/src/jcloud_docsgen/__main__.py b/src/jcloud_docsgen/__main__.py index 57403ce..7de7226 100644 --- a/src/jcloud_docsgen/__main__.py +++ b/src/jcloud_docsgen/__main__.py @@ -13,6 +13,7 @@ # limitations under the License. import sys + from .cli.cli import main if __name__ == '__main__': diff --git a/src/jcloud_docsgen/cli/__init__.py b/src/jcloud_docsgen/cli/__init__.py index f1ada26..0008773 100644 --- a/src/jcloud_docsgen/cli/__init__.py +++ b/src/jcloud_docsgen/cli/__init__.py @@ -12,8 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from . import cli -from . import languages +from . import cli, languages from .cli import main __all__ = [ diff --git a/src/jcloud_docsgen/cli/cli.py b/src/jcloud_docsgen/cli/cli.py index 1ebdce9..ae22588 100644 --- a/src/jcloud_docsgen/cli/cli.py +++ b/src/jcloud_docsgen/cli/cli.py @@ -19,6 +19,7 @@ The command line interface import argparse import pathlib import sys + from .languages.python import VALID_SECTIONS as VALID_PYTHON_SECTIONS __all__ = [ @@ -169,7 +170,7 @@ def main(argv=None) -> int: except SyntaxError: # TODO: add a custom exception class to clearify that a project # parsing syntax error is meant. - return error(f'syntax error in project source code') + return error('syntax error in project source code') except KeyboardInterrupt: return 130 except BrokenPipeError: diff --git a/src/jcloud_docsgen/cli/languages/python.py b/src/jcloud_docsgen/cli/languages/python.py index df0dff6..ae74fe9 100644 --- a/src/jcloud_docsgen/cli/languages/python.py +++ b/src/jcloud_docsgen/cli/languages/python.py @@ -13,11 +13,11 @@ # limitations under the License. import pathlib + from ...core.python import ( PythonDefinitionDocumentationIncludeSections, PythonDocumentationGenerator, ) -from typing import Optional __all__ = [ 'VALID_SECTIONS', @@ -31,7 +31,7 @@ VALID_SECTIONS = list( def parse_sections_list( - include_sections: Optional[list[str]] = None, + include_sections: list[str] | None = None, exclude_sections: list[str] = [], ) -> PythonDefinitionDocumentationIncludeSections: """ @@ -41,7 +41,7 @@ def parse_sections_list( the section name. :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. :type exclude_sections: list[str] @@ -110,7 +110,7 @@ def generate( project_directory: pathlib.Path, output_directory: pathlib.Path, *, - include_sections: Optional[list[str]] = None, + include_sections: list[str] | None = None, exclude_sections: list[str] = [], allow_html: bool = False, allow_tables: bool = False, @@ -124,7 +124,7 @@ def generate( :type output_directory: pathlib.Path :param include_sections: The sections to be included in the documentation. - :type include_sections: Optional[list[str]] + :type include_sections: list[str] | None :param exclude_sections: The sections to be excluded in the documentation. :type exclude_sections: list[str] diff --git a/src/jcloud_docsgen/core/python/__init__.py b/src/jcloud_docsgen/core/python/__init__.py index 89ef350..1213677 100644 --- a/src/jcloud_docsgen/core/python/__init__.py +++ b/src/jcloud_docsgen/core/python/__init__.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from . import namespaces from ._core import * from ._core import __all__ as _core__all__ -from . import namespaces __all__ = [ *_core__all__, diff --git a/src/jcloud_docsgen/core/python/_core.py b/src/jcloud_docsgen/core/python/_core.py index 5fe9d1b..b948125 100644 --- a/src/jcloud_docsgen/core/python/_core.py +++ b/src/jcloud_docsgen/core/python/_core.py @@ -13,25 +13,26 @@ # limitations under the License. from __future__ import annotations -from ...utils import non_empty_str, get_relative_path_segments -from ...exceptions import PythonArgumentStructureError, InvalidNamespaceError -from .namespaces import PythonModuleNamespace, PythonPackageNamespace + +import ast +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 ( PythonAsyncFunctionDefinition, PythonClassDefinition, PythonDefinition, PythonFunctionDefinition, ) -from .arguments import PythonArgumentKind, PythonFunctionArgument from .docstrings import PythonDocstring -from collections.abc import Iterator -from typing import TypeAlias, Union -from dataclasses import dataclass -from enum import Enum -import docstring_parser -import pathlib -import ast -import types +from .namespaces import PythonModuleNamespace, PythonPackageNamespace __all__ = [ 'PythonDefinitionDocumentationIncludeSections', @@ -63,9 +64,9 @@ def _collect_definitions(tree_or_node) -> Iterator[PythonDefinition]: _Arguments: TypeAlias = tuple[ list[PythonFunctionArgument], list[PythonFunctionArgument], - Union[PythonFunctionArgument, None], + PythonFunctionArgument | None, list[PythonFunctionArgument], - Union[PythonFunctionArgument, None], + PythonFunctionArgument | None, ] @@ -298,12 +299,12 @@ def _markdown_table( 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. :param docstring: The docstring. - :type docstring: Union[str, PythonDocstring, None] + :type docstring: str | PythonDocstring | None :return: Whether there is a docstring. :rtype: bool @@ -320,8 +321,8 @@ def _is_docstring(docstring: Union[str, PythonDocstring, None]) -> bool: @dataclass class _FunctionParamInfo: - annotation: Union[str, None] - description: Union[str, None] + annotation: str | None + description: str | None @dataclass @@ -908,7 +909,7 @@ class PythonModuleDocumentationGenerator: :param src_directory: The directory of the source code. It is optional and only used for making the module 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. :type include_sections: PythonDefinitionDocumentationIncludeSections :param kwargs: The options for ``PythonDefinitionDocumentationGenerator``. @@ -917,7 +918,7 @@ class PythonModuleDocumentationGenerator: def __init__( self, module_path: pathlib.Path, - src_directory: Union[pathlib.Path, None] = None, + src_directory: pathlib.Path | None = None, include_sections: PythonDefinitionDocumentationIncludeSections = ( PythonDefinitionDocumentationIncludeSections() ), diff --git a/src/jcloud_docsgen/core/python/arguments.py b/src/jcloud_docsgen/core/python/arguments.py index 961b5dc..d993675 100644 --- a/src/jcloud_docsgen/core/python/arguments.py +++ b/src/jcloud_docsgen/core/python/arguments.py @@ -13,17 +13,18 @@ # limitations under the License. from __future__ import annotations -from enum import Enum -from typing import Union + import ast -from ...utils import assert_that_is_instance +import keyword +import types +from enum import Enum + from ...exceptions import ( InvalidPythonAnnotationError, InvalidPythonIdentifierError, PythonArgumentStructureError, ) -import keyword -import types +from ...utils import assert_that_is_instance __all__ = [ 'PythonArgumentKind', @@ -49,17 +50,17 @@ class PythonFunctionArgument: :param kind: The kind of the argument. :type kind: ArgumentKind :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. - :type annotation: Union[str, None] + :type annotation: str | None """ def __init__( self, name: str, kind: PythonArgumentKind, - default: Union[str, None], - annotation: Union[str, None], + default: str | None, + annotation: str | None, ) -> None: assert_that_is_instance(name, str) assert_that_is_instance(kind, PythonArgumentKind) diff --git a/src/jcloud_docsgen/core/python/definitions.py b/src/jcloud_docsgen/core/python/definitions.py index 7c9ac1d..923b80a 100644 --- a/src/jcloud_docsgen/core/python/definitions.py +++ b/src/jcloud_docsgen/core/python/definitions.py @@ -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: diff --git a/src/jcloud_docsgen/core/python/docstrings.py b/src/jcloud_docsgen/core/python/docstrings.py index 51c7285..441abb8 100644 --- a/src/jcloud_docsgen/core/python/docstrings.py +++ b/src/jcloud_docsgen/core/python/docstrings.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from enum import Enum import docstring_parser __all__ = ['PythonDocstring'] diff --git a/src/jcloud_docsgen/core/python/namespaces.py b/src/jcloud_docsgen/core/python/namespaces.py index 2dc70b7..e113583 100644 --- a/src/jcloud_docsgen/core/python/namespaces.py +++ b/src/jcloud_docsgen/core/python/namespaces.py @@ -13,13 +13,15 @@ # limitations under the License. from __future__ import annotations + +from typing import TypeAlias, Union + from ...exceptions import ( InvalidNamespaceError, - NamespaceNotFoundError, NamespaceExistsError, + NamespaceNotFoundError, ) from ...utils import assert_that_is_instance -from typing import Union, TypeAlias, Dict, List __all__ = [ 'PythonNamespace', @@ -51,7 +53,7 @@ class PythonNamespace: return f'{type(self).__name__}({self.name!r})' -PythonPackageNamespaceDictType: TypeAlias = Dict[ +PythonPackageNamespaceDictType: TypeAlias = dict[ str, Union[ str, @@ -73,7 +75,7 @@ class PythonPackageNamespace(PythonNamespace): def __init__( self, name: str, - sub_namespaces: List[PythonNamespace], + sub_namespaces: list[PythonNamespace], ) -> None: assert_that_is_instance(sub_namespaces, list) @@ -81,7 +83,7 @@ class PythonPackageNamespace(PythonNamespace): 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 ``['package', 'subpackage', 'module']``. @@ -205,7 +207,7 @@ class PythonPackageNamespace(PythonNamespace): self._sub_namespaces.append(namespace) @property - def sub_namespaces(self) -> List[PythonNamespace]: + def sub_namespaces(self) -> list[PythonNamespace]: return self._sub_namespaces diff --git a/src/jcloud_docsgen/utils.py b/src/jcloud_docsgen/utils.py index 504c180..197a292 100644 --- a/src/jcloud_docsgen/utils.py +++ b/src/jcloud_docsgen/utils.py @@ -16,11 +16,11 @@ The utilities for jcloud_docsgen """ -import pathlib -import os import errno -from typing import Union +import os +import pathlib import types +from typing import Union try: from warnings import deprecated @@ -152,11 +152,7 @@ def _list_type_names(types: list[type]) -> list[str]: def assert_that_is_instance( obj: object, - class_or_tuple: Union[ - type, - types.UnionType, - tuple[type, ...], - ], + class_or_tuple: type | types.UnionType | tuple[type, ...], ) -> None: if not isinstance(class_or_tuple, Union[type, types.UnionType, tuple]): 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``. @@ -195,10 +191,10 @@ def non_empty_str(value: Union[str, None]) -> Union[str, None]: of spaces, it is also considered empty. :param value: The value. - :type value: Union[str, None] + :type value: str | None :return: The value or ``None``. - :rtype: Union[str, None] + :rtype: str | None """ if value is None: diff --git a/tests/unit/cli/test_parser.py b/tests/unit/cli/test_parser.py index 9ababcb..c731054 100644 --- a/tests/unit/cli/test_parser.py +++ b/tests/unit/cli/test_parser.py @@ -13,6 +13,7 @@ # limitations under the License. import pytest + from jcloud_docsgen.cli.cli import create_argument_parser diff --git a/tests/unit/cli/test_python.py b/tests/unit/cli/test_python.py index c858770..70891de 100644 --- a/tests/unit/cli/test_python.py +++ b/tests/unit/cli/test_python.py @@ -13,8 +13,11 @@ # limitations under the License. import pathlib + 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.core.python import ( PythonDefinitionDocumentationIncludeSections, diff --git a/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py index 52de56d..b4ec9b5 100644 --- a/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py @@ -12,21 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest + from src.jcloud_docsgen.core.python._core import ( PythonDefinitionDocumentationGenerator, PythonDefinitionDocumentationIncludeSections, ) +from src.jcloud_docsgen.core.python.arguments import ( + PythonArgumentKind, + PythonFunctionArgument, +) from src.jcloud_docsgen.core.python.definitions import ( - PythonFunctionDefinition, PythonAsyncFunctionDefinition, PythonClassDefinition, -) -from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, - PythonArgumentKind, + PythonFunctionDefinition, ) from src.jcloud_docsgen.core.python.docstrings import PythonDocstring -import pytest def _signature_section(signature: str) -> str: diff --git a/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py index 047da87..c97d66f 100644 --- a/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py @@ -12,13 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pathlib + +import pytest + from src.jcloud_docsgen.core.python import PythonDocumentationGenerator from src.jcloud_docsgen.core.python.namespaces import ( PythonModuleNamespace, PythonPackageNamespace, ) -import pytest -import pathlib @pytest.mark.parametrize( diff --git a/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py index 66d9b33..d922136 100644 --- a/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pathlib + +import pytest + from src.jcloud_docsgen.core.python import PythonModuleDocumentationGenerator from src.jcloud_docsgen.exceptions import InvalidNamespaceError -import pathlib -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/_core/test__argument_kind_human_readable.py b/tests/unit/core/python/_core/test__argument_kind_human_readable.py index cd34bae..b68ed7e 100644 --- a/tests/unit/core/python/_core/test__argument_kind_human_readable.py +++ b/tests/unit/core/python/_core/test__argument_kind_human_readable.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest + from src.jcloud_docsgen.core.python._core import _argument_kind_human_readable from src.jcloud_docsgen.core.python.arguments import PythonArgumentKind -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/_core/test__collect_definitions.py b/tests/unit/core/python/_core/test__collect_definitions.py index 780694a..fdb4cc3 100644 --- a/tests/unit/core/python/_core/test__collect_definitions.py +++ b/tests/unit/core/python/_core/test__collect_definitions.py @@ -12,18 +12,20 @@ # See the License for the specific language governing permissions and # limitations under the License. +import ast + +import pytest + 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 ( PythonClassDefinition, PythonFunctionDefinition, ) -from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, - PythonArgumentKind, -) from src.jcloud_docsgen.core.python.docstrings import PythonDocstring -import pytest -import ast def module(source_code: str) -> ast.Module: diff --git a/tests/unit/core/python/_core/test__fit_row_length.py b/tests/unit/core/python/_core/test__fit_row_length.py index 50686d8..7fc904e 100644 --- a/tests/unit/core/python/_core/test__fit_row_length.py +++ b/tests/unit/core/python/_core/test__fit_row_length.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python._core import _fit_row_length import pytest +from src.jcloud_docsgen.core.python._core import _fit_row_length + @pytest.mark.parametrize( 'expected_length,row,expected', diff --git a/tests/unit/core/python/_core/test__function_params_info.py b/tests/unit/core/python/_core/test__function_params_info.py index 825d998..ccb1064 100644 --- a/tests/unit/core/python/_core/test__function_params_info.py +++ b/tests/unit/core/python/_core/test__function_params_info.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import docstring_parser +import pytest + from src.jcloud_docsgen.core.python._core import ( _function_params_info, _FunctionParamInfo, ) from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, PythonArgumentKind, + PythonFunctionArgument, ) -import pytest -import docstring_parser def docstring_args_list( diff --git a/tests/unit/core/python/_core/test__markdown_table.py b/tests/unit/core/python/_core/test__markdown_table.py index ac99ec1..ec0081a 100644 --- a/tests/unit/core/python/_core/test__markdown_table.py +++ b/tests/unit/core/python/_core/test__markdown_table.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python._core import _markdown_table import pytest +from src.jcloud_docsgen.core.python._core import _markdown_table + @pytest.mark.parametrize( ( diff --git a/tests/unit/core/python/_core/test__signature_argument_list.py b/tests/unit/core/python/_core/test__signature_argument_list.py index 485c6ef..b381864 100644 --- a/tests/unit/core/python/_core/test__signature_argument_list.py +++ b/tests/unit/core/python/_core/test__signature_argument_list.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest + from src.jcloud_docsgen.core.python._core import _signature_argument_list from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, PythonArgumentKind, + PythonFunctionArgument, ) -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py b/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py index bb11dec..7af0d65 100644 --- a/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py +++ b/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py @@ -12,13 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. +import ast + +import pytest + from src.jcloud_docsgen.core.python.arguments import ( + PythonArgumentKind, PythonASTArgumentsListParser, PythonFunctionArgument, - PythonArgumentKind, ) -import pytest -import ast def argument_list(argument_list: str) -> ast.arguments: diff --git a/tests/unit/core/python/arguments/test_PythonFunctionArgument.py b/tests/unit/core/python/arguments/test_PythonFunctionArgument.py index 5ba42b6..0652165 100644 --- a/tests/unit/core/python/arguments/test_PythonFunctionArgument.py +++ b/tests/unit/core/python/arguments/test_PythonFunctionArgument.py @@ -12,16 +12,17 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest + from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, PythonArgumentKind, + PythonFunctionArgument, ) from src.jcloud_docsgen.exceptions import ( - InvalidPythonIdentifierError, InvalidPythonAnnotationError, + InvalidPythonIdentifierError, PythonArgumentStructureError, ) -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/definitions/test_PythonClassDefinition.py b/tests/unit/core/python/definitions/test_PythonClassDefinition.py index b2f1291..61ec8ac 100644 --- a/tests/unit/core/python/definitions/test_PythonClassDefinition.py +++ b/tests/unit/core/python/definitions/test_PythonClassDefinition.py @@ -12,18 +12,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python.definitions import ( - PythonFunctionDefinition, - PythonClassDefinition, -) +import pytest + from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, 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.exceptions import InvalidPythonIdentifierError from tests.utils.ast_node import ast_node -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/definitions/test_PythonDefinition.py b/tests/unit/core/python/definitions/test_PythonDefinition.py index da947a5..3b87e32 100644 --- a/tests/unit/core/python/definitions/test_PythonDefinition.py +++ b/tests/unit/core/python/definitions/test_PythonDefinition.py @@ -12,10 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import pytest + from src.jcloud_docsgen.core.python.definitions import PythonDefinition from src.jcloud_docsgen.core.python.docstrings import PythonDocstring from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py b/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py index 9cad10b..f385196 100644 --- a/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py +++ b/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition +import pytest + from src.jcloud_docsgen.core.python.arguments import ( - PythonFunctionArgument, PythonArgumentKind, + PythonFunctionArgument, ) +from src.jcloud_docsgen.core.python.definitions import PythonFunctionDefinition from src.jcloud_docsgen.core.python.docstrings import PythonDocstring from src.jcloud_docsgen.exceptions import InvalidPythonIdentifierError from tests.utils.ast_node import ast_node -import pytest @pytest.mark.parametrize( diff --git a/tests/unit/core/python/namespaces/test_PythonModuleNamespace.py b/tests/unit/core/python/namespaces/test_PythonModuleNamespace.py index 612e00c..7433a84 100644 --- a/tests/unit/core/python/namespaces/test_PythonModuleNamespace.py +++ b/tests/unit/core/python/namespaces/test_PythonModuleNamespace.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python.namespaces import PythonModuleNamespace import pytest +from src.jcloud_docsgen.core.python.namespaces import PythonModuleNamespace + class StrSubclass(str): ... diff --git a/tests/unit/core/python/namespaces/test_PythonNamespace.py b/tests/unit/core/python/namespaces/test_PythonNamespace.py index 3f845bf..e4ee640 100644 --- a/tests/unit/core/python/namespaces/test_PythonNamespace.py +++ b/tests/unit/core/python/namespaces/test_PythonNamespace.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python.namespaces import PythonNamespace import pytest +from src.jcloud_docsgen.core.python.namespaces import PythonNamespace + class StrSubclass(str): ... diff --git a/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py b/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py index 05d830e..a768e7e 100644 --- a/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py +++ b/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.core.python.namespaces import ( - PythonPackageNamespace, - PythonModuleNamespace, -) import pytest + +from src.jcloud_docsgen.core.python.namespaces import ( + PythonModuleNamespace, + PythonPackageNamespace, +) from src.jcloud_docsgen.exceptions import ( - NamespaceNotFoundError, InvalidNamespaceError, + NamespaceNotFoundError, ) diff --git a/tests/unit/utils/test_assert_that_is_instance.py b/tests/unit/utils/test_assert_that_is_instance.py index f51009f..739b90b 100644 --- a/tests/unit/utils/test_assert_that_is_instance.py +++ b/tests/unit/utils/test_assert_that_is_instance.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.utils import assert_that_is_instance -import pytest import types +import pytest + +from src.jcloud_docsgen.utils import assert_that_is_instance + class TestType: ... diff --git a/tests/unit/utils/test_get_relative_path_segments.py b/tests/unit/utils/test_get_relative_path_segments.py index a418afd..c69fc9c 100644 --- a/tests/unit/utils/test_get_relative_path_segments.py +++ b/tests/unit/utils/test_get_relative_path_segments.py @@ -12,10 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.utils import get_relative_path_segments -import pytest import pathlib +import pytest + +from src.jcloud_docsgen.utils import get_relative_path_segments + @pytest.mark.parametrize( 'path,root,expected', diff --git a/tests/unit/utils/test_human_readable_list.py b/tests/unit/utils/test_human_readable_list.py index 55d1542..12f7f83 100644 --- a/tests/unit/utils/test_human_readable_list.py +++ b/tests/unit/utils/test_human_readable_list.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.utils import human_readable_list import pytest +from src.jcloud_docsgen.utils import human_readable_list + @pytest.mark.parametrize( 'ls,final_separator,quotation_mark,expected', diff --git a/tests/unit/utils/test_non_empty_str.py b/tests/unit/utils/test_non_empty_str.py index 3f366ec..2ce7b11 100644 --- a/tests/unit/utils/test_non_empty_str.py +++ b/tests/unit/utils/test_non_empty_str.py @@ -12,9 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from src.jcloud_docsgen.utils import non_empty_str import pytest +from src.jcloud_docsgen.utils import non_empty_str + @pytest.mark.parametrize( 'value,expected', diff --git a/tests/utils/ast_node.py b/tests/utils/ast_node.py index 1b164a0..22dd1fc 100644 --- a/tests/utils/ast_node.py +++ b/tests/utils/ast_node.py @@ -12,13 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from typing import Union import ast __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. @@ -26,7 +25,7 @@ def ast_node(statement: str) -> Union[ast.stmt, None]: :type statement: str :return: The node. - :rtype: Union[ast.stmt, None] + :rtype: ast.stmt | None """ body = ast.parse(statement).body