diff --git a/src/jcloud_docsgen/__init__.py b/src/jcloud_docsgen/__init__.py index f87b366..8989209 100644 --- a/src/jcloud_docsgen/__init__.py +++ b/src/jcloud_docsgen/__init__.py @@ -18,5 +18,5 @@ from .core import __all__ as _core__all__ __all__ = [ 'cli', - *_core__all__ + *_core__all__, ] diff --git a/src/jcloud_docsgen/cli/__init__.py b/src/jcloud_docsgen/cli/__init__.py index f9d1488..f1ada26 100644 --- a/src/jcloud_docsgen/cli/__init__.py +++ b/src/jcloud_docsgen/cli/__init__.py @@ -19,5 +19,5 @@ from .cli import main __all__ = [ 'cli', 'languages', - 'main' + 'main', ] diff --git a/src/jcloud_docsgen/cli/cli.py b/src/jcloud_docsgen/cli/cli.py index 126c2ba..4205064 100644 --- a/src/jcloud_docsgen/cli/cli.py +++ b/src/jcloud_docsgen/cli/cli.py @@ -25,7 +25,7 @@ __all__ = [ 'existing_directory', 'error', 'create_argument_parser', - 'main' + 'main', ] _LANG_PYTHON = 'python' @@ -70,33 +70,33 @@ def create_argument_parser() -> argparse.ArgumentParser: type = existing_directory, nargs = '?', default = pathlib.Path('.'), - help = 'The directory of the project' + help = 'The directory of the project', ) common_parser.add_argument( '-o', '--output-dir', type = pathlib.Path, - help = 'the output directory the documentation will be written to' + help = 'the output directory the documentation will be written to', ) argument_parser = argparse.ArgumentParser() subparsers = argument_parser.add_subparsers( dest = 'language', - required = True + required = True, ) python_parser = subparsers.add_parser( _LANG_PYTHON, parents = [common_parser], - help = 'generate documentation for Python project' + help = 'generate documentation for Python project', ) python_parser.add_argument( '-s', '--sections', nargs = '+', choices = VALID_PYTHON_SECTIONS, - help = 'the sections to be included in the documentation' + help = 'the sections to be included in the documentation', ) python_parser.add_argument( '-S', @@ -107,7 +107,7 @@ def create_argument_parser() -> argparse.ArgumentParser: help = ( 'the sections to be excluded in the documentation. ' 'If a section shall be included AND excluded, it is excluded.' - ) + ), ) python_parser.add_argument( '-H', @@ -116,7 +116,7 @@ def create_argument_parser() -> argparse.ArgumentParser: help = ( 'indicates whether HTML is allowed in the documentation. ' 'By default, HTML is disabled.' - ) + ), ) python_parser.add_argument( '-T', @@ -126,7 +126,7 @@ def create_argument_parser() -> argparse.ArgumentParser: 'indicates whether Markdown tables are allowed in the ' 'documentation. By default, Markdown tables are disabled. ' 'Warning: Markdown tables are not CommonMark.' - ) + ), ) return argument_parser @@ -147,7 +147,7 @@ def main(argv = None) -> int: include_sections = args.sections, exclude_sections = args.sections_exclude, allow_html = args.allow_html, - allow_tables = args.allow_tables + allow_tables = args.allow_tables, ) except FileNotFoundError as exc: return error(f'{exc.filename}: no such file or directory') diff --git a/src/jcloud_docsgen/cli/languages/__init__.py b/src/jcloud_docsgen/cli/languages/__init__.py index f774970..78668b3 100644 --- a/src/jcloud_docsgen/cli/languages/__init__.py +++ b/src/jcloud_docsgen/cli/languages/__init__.py @@ -15,5 +15,5 @@ from . import python __all__ = [ - 'python' + 'python', ] diff --git a/src/jcloud_docsgen/cli/languages/python.py b/src/jcloud_docsgen/cli/languages/python.py index e5ed08e..ab4bbce 100644 --- a/src/jcloud_docsgen/cli/languages/python.py +++ b/src/jcloud_docsgen/cli/languages/python.py @@ -15,14 +15,14 @@ import pathlib from ...core.python import ( PythonDefinitionDocumentationIncludeSections, - PythonDocumentationGenerator + PythonDocumentationGenerator, ) from typing import Optional __all__ = [ 'VALID_SECTIONS', 'parse_sections_list', - 'generate' + 'generate', ] VALID_SECTIONS = list( @@ -31,7 +31,7 @@ VALID_SECTIONS = list( def parse_sections_list( include_sections: Optional[list[str]] = None, - exclude_sections: list[str] = [] + exclude_sections: list[str] = [], ) -> PythonDefinitionDocumentationIncludeSections: ''' Returns a Python definition documentation sections list from the @@ -64,7 +64,7 @@ def parse_sections_list( docstring = 'docstring' in include_sections, bases = 'bases' in include_sections, decorators = 'decorators' in include_sections, - class_body = 'class_body' in include_sections + class_body = 'class_body' in include_sections, ) def _generate( @@ -75,7 +75,7 @@ def _generate( PythonDefinitionDocumentationIncludeSections() ), allow_html: bool = False, - allow_tables: bool = False + allow_tables: bool = False, ) -> None: ''' Generates the documentation for a Python project. @@ -99,7 +99,7 @@ def _generate( output_directory, include_sections = include_sections, allow_html = allow_html, - allow_tables = allow_tables + allow_tables = allow_tables, ) docs_generator.generate_documentation() @@ -110,7 +110,7 @@ def generate( include_sections: Optional[list[str]] = None, exclude_sections: list[str] = [], allow_html: bool = False, - allow_tables: bool = False + allow_tables: bool = False, ) -> None: ''' Generates the documentation for a Python project. @@ -139,5 +139,5 @@ def generate( output_directory, include_sections = sections, allow_html = allow_html, - allow_tables = allow_tables + allow_tables = allow_tables, ) diff --git a/src/jcloud_docsgen/core/__init__.py b/src/jcloud_docsgen/core/__init__.py index f774970..78668b3 100644 --- a/src/jcloud_docsgen/core/__init__.py +++ b/src/jcloud_docsgen/core/__init__.py @@ -15,5 +15,5 @@ from . import python __all__ = [ - 'python' + 'python', ] diff --git a/src/jcloud_docsgen/core/python/__init__.py b/src/jcloud_docsgen/core/python/__init__.py index 08de6d0..89ef350 100644 --- a/src/jcloud_docsgen/core/python/__init__.py +++ b/src/jcloud_docsgen/core/python/__init__.py @@ -18,5 +18,5 @@ from . import namespaces __all__ = [ *_core__all__, - 'namespaces' + 'namespaces', ] diff --git a/src/jcloud_docsgen/core/python/_core.py b/src/jcloud_docsgen/core/python/_core.py index 7be8d77..cf4ba2c 100644 --- a/src/jcloud_docsgen/core/python/_core.py +++ b/src/jcloud_docsgen/core/python/_core.py @@ -20,7 +20,7 @@ from .definitions import ( PythonAsyncFunctionDefinition, PythonClassDefinition, PythonDefinition, - PythonFunctionDefinition + PythonFunctionDefinition, ) from .arguments import PythonArgumentKind, PythonFunctionArgument from .docstrings import PythonDocstring @@ -63,11 +63,11 @@ _Arguments: TypeAlias = tuple[ list[PythonFunctionArgument], Union[PythonFunctionArgument, None], list[PythonFunctionArgument], - Union[PythonFunctionArgument, None] + Union[PythonFunctionArgument, None], ] def _group_argument_list( - argument_list: list[PythonFunctionArgument] + argument_list: list[PythonFunctionArgument], ) -> _Arguments: ''' Groups the argument list into a list of positional-only arguments, a @@ -86,7 +86,7 @@ def _group_argument_list( for arg in argument_list ]): raise PythonArgumentStructureError( - 'arguments cannot follow var-keyword argument' + 'arguments cannot follow var-keyword argument', ) positional_only_args = [] @@ -106,7 +106,7 @@ def _group_argument_list( if vararg is not None: raise PythonArgumentStructureError( '* argument may only appear once', - definition = arg + definition = arg, ) vararg = arg @@ -121,11 +121,11 @@ def _group_argument_list( normal_args, vararg, keyword_only_args, - kwargs + kwargs, ) def _signature_argument_list( - argument_list: list[PythonFunctionArgument] + argument_list: list[PythonFunctionArgument], ) -> list[str]: ''' Returns a list of the arguments as strings for a function signature. @@ -142,7 +142,7 @@ def _signature_argument_list( normal_args, vararg, keyword_only_args, - kwargs + kwargs, ) = _group_argument_list(argument_list) args = [] @@ -198,7 +198,7 @@ def _markdown_table( allow_markdown_table: bool = False, force_row_lengths: bool = False, one_line_values: bool = True, - missing_value: str = '--' + missing_value: str = '--', ) -> str: ''' Generates a table. @@ -247,7 +247,7 @@ def _markdown_table( "s" if header_len > 1 else "" - }, got {len(row)}' + }, got {len(row)}', ) else: row = _fit_row_length(header_len, row) @@ -273,7 +273,7 @@ def _markdown_table( "s" if header_len > 1 else "" - }, got {len(row)}' + }, got {len(row)}', ) else: row = _fit_row_length(header_len, row) @@ -358,7 +358,7 @@ def _argument_kind_human_readable(argument_kind: PythonArgumentKind) -> str: def _function_params_info( arg_list: list[PythonFunctionArgument], - docstring_arg_list: list[docstring_parser.DocstringParam] + docstring_arg_list: list[docstring_parser.DocstringParam], ) -> dict[str, _FunctionParamInfo]: ''' Returns a dictionary with the parameter info. @@ -388,7 +388,7 @@ def _function_params_info( if arg.arg_name in arg_annotations.keys(): arg_annotations[arg.arg_name] = _FunctionParamInfo( arg_annotations[arg.arg_name].annotation or arg.type_name, - arg.description + arg.description, ) return arg_annotations @@ -427,7 +427,7 @@ class PythonDefinitionDocumentationIncludeSections: docstring: bool = True, bases: bool = True, decorators: bool = True, - class_body: bool = True + class_body: bool = True, ): self.signature = signature self.returns = returns @@ -456,13 +456,13 @@ class PythonDefinitionDocumentationIncludeSections: [ key + ' = ' + repr(value) for key, value in self._args.items() - ] + ], ) + ')' def __eq__(self, value) -> str: if not isinstance( value, - PythonDefinitionDocumentationIncludeSections + PythonDefinitionDocumentationIncludeSections, ): return False return self._args == value._args @@ -505,7 +505,7 @@ class PythonDefinitionDocumentationGenerator: allow_html: bool = True, allow_tables: bool = False, skip_empty_sections: bool = True, - is_method: bool = False + is_method: bool = False, ) -> None: self.definition = definition self.include_sections = include_sections @@ -539,13 +539,13 @@ class PythonDefinitionDocumentationGenerator: if isinstance(self.definition, PythonClassDefinition): raise TypeError( - 'Cannot generate a signature of a class definition.' + 'Cannot generate a signature of a class definition.', ) signature = self.definition.name + '(' + ', '.join( _signature_argument_list( - self.definition.args - ) + self.definition.args, + ), ) + ')' if self.definition.returns is not None: @@ -616,7 +616,7 @@ class PythonDefinitionDocumentationGenerator: params_types = _function_params_info( self.definition.args, - self._docstring.params + self._docstring.params, ) if params_types: @@ -632,11 +632,11 @@ class PythonDefinitionDocumentationGenerator: ('`' + arg.default + '`') if arg.default is not None else None, - non_empty_str(params_types.get(arg.name).description) + non_empty_str(params_types.get(arg.name).description), ) for arg in self.definition.args ], - allow_markdown_table = self.allow_tables + allow_markdown_table = self.allow_tables, ) md += '\n\n' @@ -800,7 +800,7 @@ class PythonDefinitionDocumentationGenerator: allow_html = self.allow_html, allow_tables = self.allow_tables, skip_empty_sections = self.skip_empty_sections, - is_method = True + is_method = True, ).generate_documentation() + '\n\n' if not self.definition.body and not self.skip_empty_sections: @@ -896,12 +896,12 @@ class PythonModuleDocumentationGenerator: include_sections: PythonDefinitionDocumentationIncludeSections = ( PythonDefinitionDocumentationIncludeSections() ), - **kwargs + **kwargs, ) -> None: if module_path.name.count('.') > 1: raise InvalidNamespaceError( 'namespace identifier cannot contain more than one dot', - namespace_identifier = module_path.name + namespace_identifier = module_path.name, ) self.module_path = pathlib.Path(str(module_path)) @@ -956,8 +956,8 @@ class PythonModuleDocumentationGenerator: module_identifier = '.'.join( get_relative_path_segments( self.module_path, - self.src_directory - ) + self.src_directory, + ), ) if module_identifier.endswith('.py'): md += module_identifier[:-3] @@ -977,7 +977,7 @@ class PythonModuleDocumentationGenerator: definition, self.include_sections, 2, - **self.kwargs + **self.kwargs, ).generate_documentation() + '\n\n' return md.strip() @@ -990,7 +990,7 @@ def _generate_package_namespace_documentation( include_sections: PythonDefinitionDocumentationIncludeSections = ( PythonDefinitionDocumentationIncludeSections() ), - kwargs: dict = {} + kwargs: dict = {}, ) -> None: ''' Generates the documentation for a package namespace and writes it to @@ -1021,7 +1021,7 @@ def _generate_package_namespace_documentation( documentation_directory / sub_namespace.name, root_directory, dir / sub_namespace.name, include_sections, - kwargs + kwargs, ) elif isinstance(sub_namespace, PythonModuleNamespace): ( @@ -1031,7 +1031,7 @@ def _generate_package_namespace_documentation( pathlib.Path(str(dir / (sub_namespace.name + '.py'))), pathlib.Path(str(root_directory)), include_sections, - **kwargs + **kwargs, ).generate_documentation() ) @@ -1055,7 +1055,7 @@ class PythonDocumentationGenerator: include_sections: PythonDefinitionDocumentationIncludeSections = ( PythonDefinitionDocumentationIncludeSections() ), - **kwargs + **kwargs, ) -> None: self.project_directory = pathlib.Path(str(project_directory)) self.docs_directory = pathlib.Path(str(docs_directory)) @@ -1100,5 +1100,5 @@ class PythonDocumentationGenerator: self.project_directory / 'src', self.project_directory / 'src', self.include_sections, - self.kwargs + self.kwargs, ) diff --git a/src/jcloud_docsgen/core/python/arguments.py b/src/jcloud_docsgen/core/python/arguments.py index 4caa419..9140fd8 100644 --- a/src/jcloud_docsgen/core/python/arguments.py +++ b/src/jcloud_docsgen/core/python/arguments.py @@ -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 diff --git a/src/jcloud_docsgen/core/python/definitions.py b/src/jcloud_docsgen/core/python/definitions.py index 905cee7..f54a98a 100644 --- a/src/jcloud_docsgen/core/python/definitions.py +++ b/src/jcloud_docsgen/core/python/definitions.py @@ -26,7 +26,7 @@ __all__ = [ 'PythonDefinition', 'PythonFunctionDefinition', 'PythonAsyncFunctionDefinition', - 'PythonClassDefinition' + 'PythonClassDefinition', ] def _python_docstring(doc: Union[str, None]) -> Union[PythonDocstring, None]: @@ -63,12 +63,12 @@ class PythonDefinition: self, name: str, doc: Union[PythonDocstring, None], - decorators: list[str] + decorators: list[str], ) -> None: if keyword.iskeyword(name) or not name.isidentifier() or not name: raise InvalidPythonIdentifierError( 'invalid identifier', - identifier = name + identifier = name, ) assert_that_is_instance(doc, (PythonDocstring, types.NoneType)) @@ -81,7 +81,7 @@ class PythonDefinition: return ( self.name, self.doc, - self.decorators + self.decorators, ) def __repr__(self) -> str: @@ -99,7 +99,7 @@ class PythonDefinition: return cls( node.name, _python_docstring(ast.get_docstring(node)), - [ast.unparse(d) for d in node.decorator_list] + [ast.unparse(d) for d in node.decorator_list], ) def __eq__(self, value: object) -> bool: @@ -133,7 +133,7 @@ class PythonFunctionDefinition(PythonDefinition): args: list[PythonFunctionArgument], returns: Union[str, None], doc: Union[PythonDocstring, None], - decorators: list[str] + decorators: list[str], ) -> None: super().__init__(name, doc, decorators) self.args = args @@ -145,7 +145,7 @@ class PythonFunctionDefinition(PythonDefinition): self.args, self.returns, self.doc, - self.decorators + self.decorators, ) @classmethod @@ -162,7 +162,7 @@ class PythonFunctionDefinition(PythonDefinition): PythonASTArgumentsListParser(node.args).to_argument_list(), ast.unparse(node.returns) if node.returns is not None else None, _python_docstring(ast.get_docstring(node)), - [ast.unparse(d) for d in node.decorator_list] + [ast.unparse(d) for d in node.decorator_list], ) class PythonAsyncFunctionDefinition(PythonFunctionDefinition): @@ -210,7 +210,7 @@ class PythonClassDefinition(PythonDefinition): bases: list[str], doc: Union[PythonDocstring, None], decorators: list[str], - body: list[PythonDefinition] + body: list[PythonDefinition], ) -> None: super().__init__(name, doc, decorators) self.bases = bases @@ -222,7 +222,7 @@ class PythonClassDefinition(PythonDefinition): self.bases, self.doc, self.decorators, - self.body + self.body, ) @classmethod @@ -253,5 +253,5 @@ class PythonClassDefinition(PythonDefinition): expr, (ast.FunctionDef, ast.AsyncFunctionDef, ast.ClassDef) ) - ] + ], ) diff --git a/src/jcloud_docsgen/core/python/namespaces.py b/src/jcloud_docsgen/core/python/namespaces.py index 3cef5d1..ad3218d 100644 --- a/src/jcloud_docsgen/core/python/namespaces.py +++ b/src/jcloud_docsgen/core/python/namespaces.py @@ -16,7 +16,7 @@ from __future__ import annotations from ...exceptions import ( InvalidNamespaceError, NamespaceNotFoundError, - NamespaceExistsError + NamespaceExistsError, ) from ...utils import assert_that_is_instance from typing import Union, TypeAlias, Dict, List @@ -24,7 +24,7 @@ from typing import Union, TypeAlias, Dict, List __all__ = [ 'PythonNamespace', 'PythonPackageNamespace', - 'PythonModuleNamespace' + 'PythonModuleNamespace', ] class PythonNamespace: @@ -40,7 +40,7 @@ class PythonNamespace: if not name.strip(): raise InvalidNamespaceError( 'invalid namespace', - namespace_identifier = name + namespace_identifier = name, ) self.name = name @@ -52,8 +52,8 @@ PythonPackageNamespaceDictType: TypeAlias = Dict[ str, Union[ str, - 'PythonPackageNamespaceDictType' - ] + 'PythonPackageNamespaceDictType', + ], ] class PythonPackageNamespace(PythonNamespace): @@ -69,7 +69,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) @@ -113,7 +113,7 @@ class PythonPackageNamespace(PythonNamespace): def _sub_namespaces_names( self, - package: PythonPackageNamespace + package: PythonPackageNamespace, ) -> PythonPackageNamespaceDictType: ''' Returns the names of all sub-namespaces of the specified package @@ -177,7 +177,7 @@ class PythonPackageNamespace(PythonNamespace): raise NamespaceNotFoundError( 'no such namespace', - namespace_identifier = name + namespace_identifier = name, ) def add(self, namespace: PythonNamespace) -> None: @@ -195,7 +195,7 @@ class PythonPackageNamespace(PythonNamespace): self.__getitem__(namespace.name) raise NamespaceExistsError( 'namespace already exists', - namespace_identifier = namespace.name + namespace_identifier = namespace.name, ) except NamespaceNotFoundError: self._sub_namespaces.append(namespace) diff --git a/src/jcloud_docsgen/utils.py b/src/jcloud_docsgen/utils.py index 724b74d..d602602 100644 --- a/src/jcloud_docsgen/utils.py +++ b/src/jcloud_docsgen/utils.py @@ -41,7 +41,7 @@ class ExistingDirectory(pathlib.Path): raise FileNotFoundError( errno.ENOENT, 'no such file or directory', - path + path, ) if not os.path.isdir(path): raise NotADirectoryError(errno.ENOTDIR, 'not a directory', path) @@ -61,7 +61,7 @@ class ExistingFile(pathlib.Path): raise FileNotFoundError( errno.ENOENT, 'no such file or directory', - path + path, ) if not os.path.isfile(path): raise IsADirectoryError(errno.EISDIR, 'is a directory', path) @@ -85,7 +85,7 @@ def _quote(string: str, quotation_mark: str) -> str: def human_readable_list( ls: list, final_separator: str = 'and', - quotation_mark: str = '' + quotation_mark: str = '', ) -> str: ''' Generates a human-readable list from a list. @@ -118,7 +118,7 @@ def human_readable_list( quotation_mark ) # quote the string representation of the object for obj in ls[:-1] # do not include the last element of the list - ] + ], ) + ' ' + final_separator + ' ' + _quote(str(ls[-1]), quotation_mark) def _list_type_names(types: list[type]) -> list[str]: @@ -140,13 +140,13 @@ def assert_that_is_instance( class_or_tuple: Union[ type, types.UnionType, - tuple[type, ...] - ] + tuple[type, ...], + ], ) -> None: if not isinstance(class_or_tuple, Union[type, types.UnionType, tuple]): raise TypeError( f'class_or_tuple: expected \'Union[type, types.UnionType, ' - f'tuple[type, ...]]\', \'got {type(class_or_tuple).__name__}\'' + f'tuple[type, ...]]\', \'got {type(class_or_tuple).__name__}\'', ) if not isinstance(obj, class_or_tuple): if isinstance(class_or_tuple, (tuple, types.UnionType)): @@ -157,13 +157,14 @@ def assert_that_is_instance( else: exception_message_expected = '' exception_message_expected += human_readable_list( - _list_type_names(class_or_tuple), 'or', '\'') + _list_type_names(class_or_tuple), 'or', '\'', + ) else: exception_message_expected = '\'' + class_or_tuple.__name__ + '\'' raise TypeError( f'expected {exception_message_expected}, got \'{type( obj - ).__name__}\'' + ).__name__}\'', ) def non_empty_str(value: Union[str, None]) -> Union[str, None]: @@ -192,7 +193,7 @@ def non_empty_str(value: Union[str, None]) -> Union[str, None]: def get_relative_path_segments( path: pathlib.Path, - root: pathlib.Path + root: pathlib.Path, ) -> list[str]: ''' Returns the path segments relative to ``root``. @@ -209,7 +210,7 @@ def get_relative_path_segments( return list( path.resolve() .relative_to( - root.resolve() + root.resolve(), ) - .parts + .parts, ) diff --git a/tests/integration/cli/test_cli.py b/tests/integration/cli/test_cli.py index 1e2d1f1..8e56a32 100644 --- a/tests/integration/cli/test_cli.py +++ b/tests/integration/cli/test_cli.py @@ -21,10 +21,10 @@ def test_cli(): sys.executable, '-m', 'jcloud_docsgen', - '--help' + '--help', ], capture_output = True, - text = True + text = True, ) stdout = result.stdout.lower() assert \ diff --git a/tests/unit/cli/test_parser.py b/tests/unit/cli/test_parser.py index 7eb5a19..7666e59 100644 --- a/tests/unit/cli/test_parser.py +++ b/tests/unit/cli/test_parser.py @@ -18,7 +18,7 @@ from jcloud_docsgen.cli.cli import create_argument_parser @pytest.mark.parametrize('lang', [ 'javascript', 'Python', - 'PYTHON' + 'PYTHON', ]) def test_language_error(lang): parser = create_argument_parser() @@ -27,7 +27,7 @@ def test_language_error(lang): parser.parse_args([lang]) @pytest.mark.parametrize('lang', [ - 'python' + 'python', ]) def test_language_success(lang): parser = create_argument_parser() diff --git a/tests/unit/cli/test_python.py b/tests/unit/cli/test_python.py index 2b4b98f..9b11ff0 100644 --- a/tests/unit/cli/test_python.py +++ b/tests/unit/cli/test_python.py @@ -33,8 +33,8 @@ from jcloud_docsgen.core.python import ( docstring = False, bases = False, decorators = False, - class_body = False - ) + class_body = False, + ), ), ( [], @@ -48,8 +48,8 @@ from jcloud_docsgen.core.python import ( docstring = False, bases = False, decorators = False, - class_body = False - ) + class_body = False, + ), ), ( ['signature'], @@ -63,8 +63,8 @@ from jcloud_docsgen.core.python import ( docstring = False, bases = False, decorators = False, - class_body = False - ) + class_body = False, + ), ), ( ['signature'], @@ -78,13 +78,13 @@ from jcloud_docsgen.core.python import ( docstring = False, bases = False, decorators = False, - class_body = False - ) + class_body = False, + ), ), ( None, [], - PythonDefinitionDocumentationIncludeSections() + PythonDefinitionDocumentationIncludeSections(), ), ( ['signature', 'exceptions', 'bases', 'class_body'], @@ -98,8 +98,8 @@ from jcloud_docsgen.core.python import ( docstring = False, bases = False, decorators = False, - class_body = True - ) + class_body = True, + ), ), ( None, @@ -113,8 +113,8 @@ from jcloud_docsgen.core.python import ( docstring = False, bases = True, decorators = True, - class_body = True - ) + class_body = True, + ), ) ]) def test_parse_sections_list(include, exclude, expected): @@ -127,7 +127,7 @@ def test_sections_error(): parser.parse_args([ 'python', '-s', - 'param' # correct: `params` + 'param', # correct: `params` ]) with pytest.raises(SystemExit): @@ -135,7 +135,7 @@ def test_sections_error(): 'python', '-s', 'params', - 'docstrng' # correct: `docstring` + 'docstrng', # correct: `docstring` ]) def test_sections_success(): @@ -144,13 +144,13 @@ def test_sections_success(): parser.parse_args([ 'python', '-s', - 'params' + 'params', ]) parser.parse_args([ 'python', '-s', 'params', - 'docstring' + 'docstring', ]) def test_docs_generation(expectdir): @@ -164,5 +164,5 @@ def test_docs_generation(expectdir): 'docstring', '-HTo', str(output_dir), - str(input_dir) + str(input_dir), ]) diff --git a/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py index 0fb7465..45d9344 100644 --- a/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonDefinitionDocumentationGenerator.py @@ -14,16 +14,16 @@ from src.jcloud_docsgen.core.python._core import ( PythonDefinitionDocumentationGenerator, - PythonDefinitionDocumentationIncludeSections + PythonDefinitionDocumentationIncludeSections, ) from src.jcloud_docsgen.core.python.definitions import ( PythonFunctionDefinition, PythonAsyncFunctionDefinition, - PythonClassDefinition + PythonClassDefinition, ) from src.jcloud_docsgen.core.python.arguments import ( PythonFunctionArgument, - PythonArgumentKind + PythonArgumentKind, ) from src.jcloud_docsgen.core.python.docstrings import PythonDocstring import pytest @@ -54,8 +54,8 @@ def _signature_section(signature: str) -> str: [], None, None, - [] - ) + [], + ), ), 'a()' ), @@ -66,8 +66,8 @@ def _signature_section(signature: str) -> str: [], 'str', None, - [] - ) + [], + ), ), 'a() -> str' ), @@ -80,15 +80,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.NORMAL, None, - None - ) + None, + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a) -> str' + 'a(a) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -98,15 +98,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.NORMAL, None, - 'str' - ) + 'str', + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a: str) -> str' + 'a(a: str) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -117,15 +117,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.NORMAL, '\'42\'', - None + None, ) ], 'str', None, - [] - ) + [], + ), ), - 'a(a = \'42\') -> str' + 'a(a = \'42\') -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -136,15 +136,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.NORMAL, '\'42\'', - 'str' + 'str', ) ], 'str', None, - [] - ) + [], + ), ), - 'a(a: str = \'42\') -> str' + 'a(a: str = \'42\') -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -155,15 +155,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.POSITIONAL_ONLY, '\'42\'', - 'str' + 'str', ) ], 'str', None, - [] - ) + [], + ), ), - 'a(a: str = \'42\', /) -> str' + 'a(a: str = \'42\', /) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -174,15 +174,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ) ], 'str', None, - [] - ) + [], + ), ), - 'a(a, /) -> str' + 'a(a, /) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -193,15 +193,15 @@ def _signature_section(signature: str) -> str: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ) ], None, None, - [] - ) + [], + ), ), - 'a(a, /)' + 'a(a, /)', ), ( PythonDefinitionDocumentationGenerator( @@ -212,41 +212,41 @@ def _signature_section(signature: str) -> str: 'self', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'definition', PythonArgumentKind.NORMAL, None, - 'PythonDefinition' + 'PythonDefinition', ), PythonFunctionArgument( 'allow_html', PythonArgumentKind.KEYWORD_ONLY, 'True', - 'bool' + 'bool', ), PythonFunctionArgument( 'level', PythonArgumentKind.KEYWORD_ONLY, '1', - 'int' - ) + 'int', + ), ], 'None', None, - [] - ) + [], + ), ), ( '__init__(self, definition: PythonDefinition, *, ' 'allow_html: bool = True, level: int = 1) -> None' - ) + ), ), ]) def test_PythonDefinitionDocumentationGenerator_generate_signature( definition_documentation_generator, - expected + expected, ): assert definition_documentation_generator.generate_signature() == expected @@ -263,18 +263,18 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature( [], None, [], - [] - ) + [], + ), ), TypeError, - 'Cannot generate a signature of a class definition.' - ) - ] + 'Cannot generate a signature of a class definition.', + ), + ], ) def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( definition_documentation_generator, expected_exception, - expected_exception_msg + expected_exception_msg, ): with pytest.raises(expected_exception) as exc_info: definition_documentation_generator.generate_signature() @@ -288,10 +288,10 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( [], None, None, - [] - ) + [], + ), ), - 'a()' + 'a()', ), ( PythonDefinitionDocumentationGenerator( @@ -300,10 +300,10 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( [], 'str', None, - [] - ) + [], + ), ), - 'a() -> str' + 'a() -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -314,15 +314,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.NORMAL, None, - None - ) + None, + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a) -> str' + 'a(a) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -333,15 +333,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.NORMAL, None, - 'str' - ) + 'str', + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a: str) -> str' + 'a(a: str) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -352,15 +352,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.NORMAL, '\'42\'', - None - ) + None, + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a = \'42\') -> str' + 'a(a = \'42\') -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -371,15 +371,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.NORMAL, '\'42\'', - 'str' - ) + 'str', + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a: str = \'42\') -> str' + 'a(a: str = \'42\') -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -390,15 +390,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.POSITIONAL_ONLY, '\'42\'', - 'str' - ) + 'str', + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a: str = \'42\', /) -> str' + 'a(a: str = \'42\', /) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -409,15 +409,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None - ) + None, + ), ], 'str', None, - [] - ) + [], + ), ), - 'a(a, /) -> str' + 'a(a, /) -> str', ), ( PythonDefinitionDocumentationGenerator( @@ -428,15 +428,15 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None - ) + None, + ), ], None, None, - [] - ) + [], + ), ), - 'a(a, /)' + 'a(a, /)', ), ( PythonDefinitionDocumentationGenerator( @@ -447,41 +447,41 @@ def test_PythonDefinitionDocumentationGenerator_generate_signature_exceptions( 'self', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'definition', PythonArgumentKind.NORMAL, None, - 'PythonDefinition' + 'PythonDefinition', ), PythonFunctionArgument( 'allow_html', PythonArgumentKind.KEYWORD_ONLY, 'True', - 'bool' + 'bool', ), PythonFunctionArgument( 'level', PythonArgumentKind.KEYWORD_ONLY, '1', - 'int' + 'int', ), ], 'None', None, - [] - ) + [], + ), ), ( '__init__(self, definition: PythonDefinition, *, ' 'allow_html: bool = True, level: int = 1) -> None' - ) + ), ), ]) def test_PythonDefinitionDocumentationGenerator__generate_signature_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_signature_section() @@ -496,12 +496,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, None, - [] + [], ), allow_html = False, - skip_empty_sections = True + skip_empty_sections = True, ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -510,12 +510,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring(''), - [] + [], ), allow_html = False, - skip_empty_sections = True + skip_empty_sections = True, ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -524,12 +524,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a'), - [] + [], ), allow_html = False, - skip_empty_sections = True + skip_empty_sections = True, ), - '## Docstring\n\na' + '## Docstring\n\na', ), ( PythonDefinitionDocumentationGenerator( @@ -538,12 +538,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a\nb'), - [] + [], ), allow_html = False, - skip_empty_sections = True + skip_empty_sections = True, ), - '## Docstring\n\na\nb' + '## Docstring\n\na\nb', ), ( @@ -553,12 +553,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, None, - [] + [], ), allow_html = True, - skip_empty_sections = True + skip_empty_sections = True, ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -567,12 +567,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring(''), - [] + [], ), allow_html = True, - skip_empty_sections = True + skip_empty_sections = True, ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -581,15 +581,15 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a'), - [] + [], ), allow_html = True, - skip_empty_sections = True + skip_empty_sections = True, ), ( '

Docstring

a
' - ) + ), ), ( PythonDefinitionDocumentationGenerator( @@ -598,15 +598,15 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a\nb'), - [] + [], ), allow_html = True, - skip_empty_sections = True + skip_empty_sections = True, ), ( '

Docstring

a\nb
' - ) + ), ), ( @@ -616,12 +616,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, None, - [] + [], ), allow_html = False, - skip_empty_sections = False + skip_empty_sections = False, ), - '## Docstring\n\nThere is no docstring to show.' + '## Docstring\n\nThere is no docstring to show.', ), ( PythonDefinitionDocumentationGenerator( @@ -630,12 +630,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring(''), - [] + [], ), allow_html = False, - skip_empty_sections = False + skip_empty_sections = False, ), - '## Docstring\n\nThere is no docstring to show.' + '## Docstring\n\nThere is no docstring to show.', ), ( PythonDefinitionDocumentationGenerator( @@ -644,12 +644,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a'), - [] + [], ), allow_html = False, - skip_empty_sections = False + skip_empty_sections = False, ), - '## Docstring\n\na' + '## Docstring\n\na', ), ( PythonDefinitionDocumentationGenerator( @@ -658,12 +658,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a\nb'), - [] + [], ), allow_html = False, - skip_empty_sections = False + skip_empty_sections = False, ), - '## Docstring\n\na\nb' + '## Docstring\n\na\nb', ), ( @@ -673,15 +673,15 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, None, - [] + [], ), allow_html = True, - skip_empty_sections = False + skip_empty_sections = False, ), ( '

Docstring<' '/h2>

There is no docstring to show.
' - ) + ), ), ( PythonDefinitionDocumentationGenerator( @@ -690,15 +690,15 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring(''), - [] + [], ), allow_html = True, - skip_empty_sections = False + skip_empty_sections = False, ), ( '

Docstring<' '/h2>

There is no docstring to show.
' - ) + ), ), ( PythonDefinitionDocumentationGenerator( @@ -707,15 +707,15 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a'), - [] + [], ), allow_html = True, - skip_empty_sections = False + skip_empty_sections = False, ), ( '

Docstring

a
' - ) + ), ), ( PythonDefinitionDocumentationGenerator( @@ -724,21 +724,20 @@ def test_PythonDefinitionDocumentationGenerator__generate_signature_section( [], None, PythonDocstring('a\nb'), - [] + [], ), allow_html = True, - skip_empty_sections = False + skip_empty_sections = False, ), ( '

Docstring

a\nb
' - ) + ), ), - ]) def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_docstring_section() @@ -753,10 +752,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( [], None, None, - [] - ) + [], + ), ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -765,11 +764,11 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( [], None, None, - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), - '## Parameters\n\nThis function takes no parameters.' + '## Parameters\n\nThis function takes no parameters.', ), ( @@ -781,13 +780,13 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - None + None, ) ], None, None, - [] - ) + [], + ), ), '''## Parameters @@ -799,7 +798,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: -- - Description: --''' + Description: --''', ), ( @@ -811,13 +810,13 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, '1', - None + None, ) ], None, None, - [] - ) + [], + ), ), '''## Parameters @@ -829,7 +828,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: `1` - Description: --''' + Description: --''', ), ( @@ -841,13 +840,13 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ) ], None, None, - [] - ) + [], + ), ), '''## Parameters @@ -859,7 +858,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: -- - Description: --''' + Description: --''', ), ( @@ -871,13 +870,13 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, '1', - 'int' + 'int', ) ], None, None, - [] - ) + [], + ), ), '''## Parameters @@ -889,7 +888,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: `1` - Description: --''' + Description: --''', ), ( @@ -901,19 +900,19 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ) ], None, None, - [] - ) + [], + ), ), '''## Parameters @@ -935,7 +934,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: -- - Description: --''' + Description: --''', ), ( @@ -947,19 +946,19 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None - ) + None, + ), ], None, PythonDocstring(':param b: a parameter\n:type b: int'), - [] - ) + [], + ), ), '''## Parameters @@ -981,7 +980,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: -- - Description: a parameter''' + Description: a parameter''', ), ( @@ -993,21 +992,21 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), ], None, PythonDocstring( - ':param b:\n:type b: int' + ':param b:\n:type b: int', ), - [] - ) + [], + ), ), '''## Parameters - Parameter: `a` @@ -1028,7 +1027,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: -- - Description: --''' + Description: --''', ), ( @@ -1040,19 +1039,19 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), ], None, PythonDocstring(':param b: \n:type b: int'), - [] - ) + [], + ), ), '''## Parameters - Parameter: `a` @@ -1073,7 +1072,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( Default value: -- - Description: --''' + Description: --''', ), ( @@ -1084,32 +1083,32 @@ def test_PythonDefinitionDocumentationGenerator__generate_docstring_section( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), ], None, PythonDocstring(':param b: a parameter\n:type b: int'), - [] + [], ), - allow_tables = True + allow_tables = True, ), '''## Parameters | Parameter | Type | Kind | Default value | Description | | --- | --- | --- | --- | --- | | `a` | -- | normal | -- | -- | -| `b` | `int` | positional-only | -- | a parameter |''' +| `b` | `int` | positional-only | -- | a parameter |''', ), ]) def test_PythonDefinitionDocumentationGenerator__generate_params_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_params_section() @@ -1124,23 +1123,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_params_section( [], None, None, - [] - ) - ), - '' - ), - ( - PythonDefinitionDocumentationGenerator( - PythonFunctionDefinition( - 'a', [], - None, - None, - [] ), - skip_empty_sections = False ), - '## Exceptions\n\nThis function raises no exceptions.' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -1148,11 +1134,28 @@ def test_PythonDefinitionDocumentationGenerator__generate_params_section( 'a', [], None, - PythonDocstring(':raises E: a'), [])), '''## Exceptions + None, + [], + ), + skip_empty_sections = False, + ), + '## Exceptions\n\nThis function raises no exceptions.', + ), + ( + PythonDefinitionDocumentationGenerator( + PythonFunctionDefinition( + 'a', + [], + None, + PythonDocstring(':raises E: a'), [], + ), + ), + '''## Exceptions - Exception: `E` - Description: a'''), + Description: a''', + ), ( PythonDefinitionDocumentationGenerator( @@ -1161,8 +1164,8 @@ def test_PythonDefinitionDocumentationGenerator__generate_params_section( [], None, PythonDocstring(':raises E:\n:raises E2:'), - [] - ) + [], + ), ), '''## Exceptions @@ -1172,7 +1175,7 @@ def test_PythonDefinitionDocumentationGenerator__generate_params_section( - Exception: `E2` - Description: --''' + Description: --''', ), ( @@ -1182,8 +1185,8 @@ def test_PythonDefinitionDocumentationGenerator__generate_params_section( [], None, PythonDocstring(':raises E:\n:raises E2: a'), - [] - ) + [], + ), ), '''## Exceptions @@ -1193,12 +1196,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_params_section( - Exception: `E2` - Description: a''' + Description: a''', ), ]) def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_exceptions_section() @@ -1213,10 +1216,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, None, - [] - ) + [], + ), ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -1225,10 +1228,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring(''), - [] - ) + [], + ), ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -1237,10 +1240,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring('Examples\n--------'), - [] - ) + [], + ), ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -1249,10 +1252,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring('Examples\n--------\n'), - [] - ) + [], + ), ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -1261,10 +1264,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring('Examples\n--------\n\n'), - [] - ) + [], + ), ), - '' + '', ), ( @@ -1274,11 +1277,11 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, None, - [] + [], ), skip_empty_sections = False ), - '## Examples\n\nThere are no examples.' + '## Examples\n\nThere are no examples.', ), ( PythonDefinitionDocumentationGenerator( @@ -1287,11 +1290,11 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring(''), - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), - '## Examples\n\nThere are no examples.' + '## Examples\n\nThere are no examples.', ), ( PythonDefinitionDocumentationGenerator( @@ -1300,11 +1303,11 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring('Examples\n--------'), - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), - '## Examples\n\nThere are no examples.' + '## Examples\n\nThere are no examples.', ), ( PythonDefinitionDocumentationGenerator( @@ -1313,11 +1316,11 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring('Examples\n--------\n'), - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), - '## Examples\n\nThere are no examples.' + '## Examples\n\nThere are no examples.', ), ( PythonDefinitionDocumentationGenerator( @@ -1326,11 +1329,11 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( [], None, PythonDocstring('Examples\n--------\n\n'), - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), - '## Examples\n\nThere are no examples.' + '## Examples\n\nThere are no examples.', ), ( @@ -1343,16 +1346,16 @@ def test_PythonDefinitionDocumentationGenerator__generate_exceptions_section( '''Examples -------- >>> a() -None''' +None''', ), - [] - ) + [], + ), ), '''## Examples ```python >>> a() -```''' +```''', ), ( @@ -1368,10 +1371,10 @@ None''' None >>> a() -None''' +None''', ), - [] - ) + [], + ), ), '''## Examples @@ -1383,7 +1386,7 @@ None''' ```python >>> a() -```''' +```''', ), ( @@ -1399,10 +1402,10 @@ None''' None >>> b() -1''' +1''', ), - [] - ) + [], + ), ), '''## Examples @@ -1414,12 +1417,12 @@ None ```python >>> b() -```''' +```''', ), ]) def test_PythonDefinitionDocumentationGenerator__generate_examples_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_examples_section() @@ -1434,12 +1437,12 @@ def test_PythonDefinitionDocumentationGenerator__generate_examples_section( [], 'int', None, - [] - ) + [], + ), ), '''## Returns -Return type: `int`''' +Return type: `int`''', ), ( @@ -1449,14 +1452,14 @@ Return type: `int`''' [], 'int', PythonDocstring(':return: value'), - [] - ) + [], + ), ), '''## Returns value -Return type: `int`''' +Return type: `int`''', ), ( @@ -1466,14 +1469,14 @@ Return type: `int`''' [], 'int', PythonDocstring(':return: value\n:rtype: str'), - [] - ) + [], + ), ), '''## Returns value -Return type: `int`''' +Return type: `int`''', ), ( @@ -1483,14 +1486,14 @@ Return type: `int`''' [], None, PythonDocstring(':return: value\n:rtype: str'), - [] - ) + [], + ), ), '''## Returns value -Return type: `str`''' +Return type: `str`''', ), ( @@ -1500,12 +1503,12 @@ Return type: `str`''' [], None, PythonDocstring(':return: value'), - [] - ) + [], + ), ), '''## Returns -value''' +value''', ), ( @@ -1515,19 +1518,19 @@ value''' [], None, PythonDocstring('a'), - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), ( '## Returns\n\nThis function does not provi' 'de any information about its return value.' - ) + ), ), ]) def test_PythonDefinitionDocumentationGenerator__generate_returns_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_returns_section() @@ -1542,8 +1545,8 @@ def test_PythonDefinitionDocumentationGenerator__generate_returns_section( [], None, None, - ['a', 'b'] - ) + ['a', 'b'], + ), ), '''## Decorators @@ -1553,7 +1556,7 @@ a ```python b -```''' +```''', ), ( PythonDefinitionDocumentationGenerator( @@ -1562,14 +1565,14 @@ b [], None, None, - ['a'] - ) + ['a'], + ), ), '''## Decorators ```python a -```''' +```''', ), ( PythonDefinitionDocumentationGenerator( @@ -1578,30 +1581,30 @@ a [], None, None, - [] - ) - ), - '' - ), - ( - PythonDefinitionDocumentationGenerator( - PythonFunctionDefinition( - 'a', [], - None, - None, - [] ), - skip_empty_sections = False + ), + '', + ), + ( + PythonDefinitionDocumentationGenerator( + PythonFunctionDefinition( + 'a', + [], + None, + None, + [], + ), + skip_empty_sections = False, ), '''## Decorators -This function or class does not have any decorators.''' +This function or class does not have any decorators.''', ), ]) def test_PythonDefinitionDocumentationGenerator__generate_decorators_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_decorators_section() @@ -1616,10 +1619,10 @@ def test_PythonDefinitionDocumentationGenerator__generate_decorators_section( [], None, [], - [] - ) + [], + ), ), - '' + '', ), ( PythonDefinitionDocumentationGenerator( @@ -1628,13 +1631,13 @@ def test_PythonDefinitionDocumentationGenerator__generate_decorators_section( [], None, [], - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), '''## Base classes -This class does not have any base classes.''' +This class does not have any base classes.''', ), ( PythonDefinitionDocumentationGenerator( @@ -1643,13 +1646,14 @@ This class does not have any base classes.''' ['a'], None, [], - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), '''## Base classes -- `a`'''), +- `a`''', + ), ( PythonDefinitionDocumentationGenerator( PythonClassDefinition( @@ -1657,13 +1661,13 @@ This class does not have any base classes.''' ['b'], None, [], - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), '''## Base classes -- `b`''' +- `b`''', ), ( PythonDefinitionDocumentationGenerator( @@ -1672,14 +1676,14 @@ This class does not have any base classes.''' ['a', 'b'], None, [], - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), '''## Base classes - `a` -- `b`''' +- `b`''', ), ( PythonDefinitionDocumentationGenerator( @@ -1688,19 +1692,19 @@ This class does not have any base classes.''' ['b', 'a'], None, [], - [] + [], ), - skip_empty_sections = False + skip_empty_sections = False, ), '''## Base classes - `b` -- `a`''' +- `a`''', ), ]) def test_PythonDefinitionDocumentationGenerator__generate_bases_section( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator._generate_bases_section() @@ -1717,25 +1721,25 @@ def test_PythonDefinitionDocumentationGenerator__generate_bases_section( 'hello', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'world', PythonArgumentKind.NORMAL, '1', - None + None, ), PythonFunctionArgument( 'something', PythonArgumentKind.KEYWORD_ONLY, '\'something\'', - 'str' + 'str', ), PythonFunctionArgument( 'value', PythonArgumentKind.KWARGS, None, - None + None, ), ], 'bool', @@ -1753,524 +1757,11 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), - ['decorate(1, 2, 3)'] - ), - allow_html = False - ), - '''# Function `a` - -A function. - -Very long ... - -## Function signature - -```python -a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool -``` - -## Returns - -The return value. - -Return type: `bool` - -## Parameters - -- Parameter: `hello` - - Type: `int` - - Kind: positional-only - - Default value: -- - - Description: A parameter. - -- Parameter: `world` - - Type: -- - - Kind: normal - - Default value: `1` - - Description: -- - -- Parameter: `something` - - Type: `str` - - Kind: keyword-only - - Default value: `'something'` - - Description: Something. - -- Parameter: `value` - - Type: `object` - - Kind: kwargs - - Default value: -- - - Description: The value. - -## Exceptions - -- Exception: `ValueError` - - Description: If the value is invalid. - -## Decorators - -```python -decorate(1, 2, 3) -``` - - - -## Docstring - -A function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list''' - ), - - - ( - PythonDefinitionDocumentationGenerator( - PythonFunctionDefinition( - 'a', - [ - PythonFunctionArgument( - 'hello', - PythonArgumentKind.POSITIONAL_ONLY, - None, - 'int' - ), - PythonFunctionArgument( - 'world', - PythonArgumentKind.NORMAL, - '1', - None - ), - PythonFunctionArgument( - 'something', - PythonArgumentKind.KEYWORD_ONLY, - '\'something\'', - 'str' - ), - PythonFunctionArgument( - 'value', - PythonArgumentKind.KWARGS, - None, - None - ), - ], - 'bool', - PythonDocstring( - '''A function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list''' - ), - ['decorate(1, 2, 3)'] - ) - ), - ( - '''# Function `a` - -A function. - -Very long ... - -## Function signature - -```python -a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool -``` - -## Returns - -The return value. - -Return type: `bool` - -## Parameters - -- Parameter: `hello` - - Type: `int` - - Kind: positional-only - - Default value: -- - - Description: A parameter. - -- Parameter: `world` - - Type: -- - - Kind: normal - - Default value: `1` - - Description: -- - -- Parameter: `something` - - Type: `str` - - Kind: keyword-only - - Default value: `'something'` - - Description: Something. - -- Parameter: `value` - - Type: `object` - - Kind: kwargs - - Default value: -- - - Description: The value. - -## Exceptions - -- Exception: `ValueError` - - Description: If the value is invalid. - -## Decorators - -```python -decorate(1, 2, 3) -``` - - - -

Docstring

A ''' - '''function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list
''' - ) - ), - - - ( - PythonDefinitionDocumentationGenerator( - PythonFunctionDefinition( - 'a', - [ - PythonFunctionArgument( - 'hello', - PythonArgumentKind.POSITIONAL_ONLY, - None, - 'int' - ), - PythonFunctionArgument( - 'world', - PythonArgumentKind.NORMAL, - '1', - None - ), - PythonFunctionArgument( - 'something', - PythonArgumentKind.KEYWORD_ONLY, - '\'something\'', - 'str' - ), - PythonFunctionArgument( - 'value', - PythonArgumentKind.KWARGS, - None, - None - ), - ], - 'bool', - PythonDocstring( - '''A function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list''' - ), - ['decorate(1, 2, 3)'] + ['decorate(1, 2, 3)'], ), allow_html = False, - allow_tables = True - ), - '''# Function `a` - -A function. - -Very long ... - -## Function signature - -```python -a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool -``` - -## Returns - -The return value. - -Return type: `bool` - -## Parameters - -| Parameter | Type | Kind | Default value | Description | -| --- | --- | --- | --- | --- | -| `hello` | `int` | positional-only | -- | A parameter. | -| `world` | -- | normal | `1` | -- | -| `something` | `str` | keyword-only | `'something'` | Something. | -| `value` | `object` | kwargs | -- | The value. | - -## Exceptions - -| Exception | Description | -| --- | --- | -| `ValueError` | If the value is invalid. | - -## Decorators - -```python -decorate(1, 2, 3) -``` - - - -## Docstring - -A function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list''' - ), - - - ( - PythonDefinitionDocumentationGenerator( - PythonFunctionDefinition( - 'a', - [ - PythonFunctionArgument( - 'hello', - PythonArgumentKind.POSITIONAL_ONLY, - None, - 'int' - ), - PythonFunctionArgument( - 'world', - PythonArgumentKind.NORMAL, - '1', - None - ), - PythonFunctionArgument( - 'something', - PythonArgumentKind.KEYWORD_ONLY, - '\'something\'', - 'str' - ), - PythonFunctionArgument( - 'value', - PythonArgumentKind.KWARGS, - None, - None - ), - ], - 'bool', - PythonDocstring( - '''A function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list''' - ), - ['decorate(1, 2, 3)'] - ), - allow_tables = True - ), - ( - '''# Function `a` - -A function. - -Very long ... - -## Function signature - -```python -a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool -``` - -## Returns - -The return value. - -Return type: `bool` - -## Parameters - -| Parameter | Type | Kind | Default value | Description | -| --- | --- | --- | --- | --- | -| `hello` | `int` | positional-only | -- | A parameter. | -| `world` | -- | normal | `1` | -- | -| `something` | `str` | keyword-only | `'something'` | Something. | -| `value` | `object` | kwargs | -- | The value. | - -## Exceptions - -| Exception | Description | -| --- | --- | -| `ValueError` | If the value is invalid. | - -## Decorators - -```python -decorate(1, 2, 3) -``` - - - -

Docstring

A ''' - '''function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list
''' - ) - ), - - - ( - PythonDefinitionDocumentationGenerator( - PythonFunctionDefinition( - 'a', - [ - PythonFunctionArgument( - 'hello', - PythonArgumentKind.POSITIONAL_ONLY, - None, - 'int' - ), - PythonFunctionArgument( - 'world', - PythonArgumentKind.NORMAL, - '1', - None - ), - PythonFunctionArgument( - 'something', - PythonArgumentKind.KEYWORD_ONLY, - '\'something\'', - 'str' - ), - PythonFunctionArgument( - 'value', - PythonArgumentKind.KWARGS, - None, - None - ), - ], - 'bool', - PythonDocstring( - '''A function. - -Very long ... - -:param hello: A parameter. -:type hello: str -:param something: Something. -:param value: The value. -:type value: object - -:raises ValueError: If the value is invalid. - -:return: The return value. -:rtype: list''' - ), - ['decorate(1, 2, 3)'] - ), - allow_html = False, - skip_empty_sections = False ), '''# Function `a` @@ -2344,9 +1835,7 @@ Return type: `bool` decorate(1, 2, 3) ``` -## Examples -There are no examples. ## Docstring @@ -2363,7 +1852,7 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), @@ -2376,25 +1865,25 @@ Very long ... 'hello', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'world', PythonArgumentKind.NORMAL, '1', - None + None, ), PythonFunctionArgument( 'something', PythonArgumentKind.KEYWORD_ONLY, '\'something\'', - 'str' + 'str', ), PythonFunctionArgument( 'value', PythonArgumentKind.KWARGS, None, - None + None, ), ], 'bool', @@ -2412,11 +1901,10 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), - ['decorate(1, 2, 3)'] + ['decorate(1, 2, 3)'], ), - skip_empty_sections = False ), ( '''# Function `a` @@ -2491,9 +1979,7 @@ Return type: `bool` decorate(1, 2, 3) ``` -## Examples -There are no examples.

Docstring

A ''' '''function. @@ -2510,7 +1996,7 @@ Very long ... :return: The return value. :rtype: list
''' - ) + ), ), @@ -2523,25 +2009,25 @@ Very long ... 'hello', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'world', PythonArgumentKind.NORMAL, '1', - None + None, ), PythonFunctionArgument( 'something', PythonArgumentKind.KEYWORD_ONLY, '\'something\'', - 'str' + 'str', ), PythonFunctionArgument( 'value', PythonArgumentKind.KWARGS, None, - None + None, ), ], 'bool', @@ -2559,13 +2045,531 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), - ['decorate(1, 2, 3)'] + ['decorate(1, 2, 3)'], ), allow_html = False, allow_tables = True, - skip_empty_sections = False + ), + '''# Function `a` + +A function. + +Very long ... + +## Function signature + +```python +a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool +``` + +## Returns + +The return value. + +Return type: `bool` + +## Parameters + +| Parameter | Type | Kind | Default value | Description | +| --- | --- | --- | --- | --- | +| `hello` | `int` | positional-only | -- | A parameter. | +| `world` | -- | normal | `1` | -- | +| `something` | `str` | keyword-only | `'something'` | Something. | +| `value` | `object` | kwargs | -- | The value. | + +## Exceptions + +| Exception | Description | +| --- | --- | +| `ValueError` | If the value is invalid. | + +## Decorators + +```python +decorate(1, 2, 3) +``` + + + +## Docstring + +A function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list''', + ), + + + ( + PythonDefinitionDocumentationGenerator( + PythonFunctionDefinition( + 'a', + [ + PythonFunctionArgument( + 'hello', + PythonArgumentKind.POSITIONAL_ONLY, + None, + 'int', + ), + PythonFunctionArgument( + 'world', + PythonArgumentKind.NORMAL, + '1', + None, + ), + PythonFunctionArgument( + 'something', + PythonArgumentKind.KEYWORD_ONLY, + '\'something\'', + 'str', + ), + PythonFunctionArgument( + 'value', + PythonArgumentKind.KWARGS, + None, + None, + ), + ], + 'bool', + PythonDocstring( + '''A function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list''', + ), + ['decorate(1, 2, 3)'], + ), + allow_tables = True, + ), + ( + '''# Function `a` + +A function. + +Very long ... + +## Function signature + +```python +a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool +``` + +## Returns + +The return value. + +Return type: `bool` + +## Parameters + +| Parameter | Type | Kind | Default value | Description | +| --- | --- | --- | --- | --- | +| `hello` | `int` | positional-only | -- | A parameter. | +| `world` | -- | normal | `1` | -- | +| `something` | `str` | keyword-only | `'something'` | Something. | +| `value` | `object` | kwargs | -- | The value. | + +## Exceptions + +| Exception | Description | +| --- | --- | +| `ValueError` | If the value is invalid. | + +## Decorators + +```python +decorate(1, 2, 3) +``` + + + +

Docstring

A ''' + '''function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list
''' + ), + ), + + + ( + PythonDefinitionDocumentationGenerator( + PythonFunctionDefinition( + 'a', + [ + PythonFunctionArgument( + 'hello', + PythonArgumentKind.POSITIONAL_ONLY, + None, + 'int', + ), + PythonFunctionArgument( + 'world', + PythonArgumentKind.NORMAL, + '1', + None, + ), + PythonFunctionArgument( + 'something', + PythonArgumentKind.KEYWORD_ONLY, + '\'something\'', + 'str', + ), + PythonFunctionArgument( + 'value', + PythonArgumentKind.KWARGS, + None, + None, + ), + ], + 'bool', + PythonDocstring( + '''A function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list''', + ), + ['decorate(1, 2, 3)'], + ), + allow_html = False, + skip_empty_sections = False, + ), + '''# Function `a` + +A function. + +Very long ... + +## Function signature + +```python +a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool +``` + +## Returns + +The return value. + +Return type: `bool` + +## Parameters + +- Parameter: `hello` + + Type: `int` + + Kind: positional-only + + Default value: -- + + Description: A parameter. + +- Parameter: `world` + + Type: -- + + Kind: normal + + Default value: `1` + + Description: -- + +- Parameter: `something` + + Type: `str` + + Kind: keyword-only + + Default value: `'something'` + + Description: Something. + +- Parameter: `value` + + Type: `object` + + Kind: kwargs + + Default value: -- + + Description: The value. + +## Exceptions + +- Exception: `ValueError` + + Description: If the value is invalid. + +## Decorators + +```python +decorate(1, 2, 3) +``` + +## Examples + +There are no examples. + +## Docstring + +A function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list''', + ), + + + ( + PythonDefinitionDocumentationGenerator( + PythonFunctionDefinition( + 'a', + [ + PythonFunctionArgument( + 'hello', + PythonArgumentKind.POSITIONAL_ONLY, + None, + 'int', + ), + PythonFunctionArgument( + 'world', + PythonArgumentKind.NORMAL, + '1', + None, + ), + PythonFunctionArgument( + 'something', + PythonArgumentKind.KEYWORD_ONLY, + '\'something\'', + 'str', + ), + PythonFunctionArgument( + 'value', + PythonArgumentKind.KWARGS, + None, + None, + ), + ], + 'bool', + PythonDocstring( + '''A function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list''', + ), + ['decorate(1, 2, 3)'], + ), + skip_empty_sections = False, + ), + ( + '''# Function `a` + +A function. + +Very long ... + +## Function signature + +```python +a(hello: int, /, world = 1, *, something: str = 'something', **value) -> bool +``` + +## Returns + +The return value. + +Return type: `bool` + +## Parameters + +- Parameter: `hello` + + Type: `int` + + Kind: positional-only + + Default value: -- + + Description: A parameter. + +- Parameter: `world` + + Type: -- + + Kind: normal + + Default value: `1` + + Description: -- + +- Parameter: `something` + + Type: `str` + + Kind: keyword-only + + Default value: `'something'` + + Description: Something. + +- Parameter: `value` + + Type: `object` + + Kind: kwargs + + Default value: -- + + Description: The value. + +## Exceptions + +- Exception: `ValueError` + + Description: If the value is invalid. + +## Decorators + +```python +decorate(1, 2, 3) +``` + +## Examples + +There are no examples. + +

Docstring

A ''' + '''function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list
''' + ), + ), + + + ( + PythonDefinitionDocumentationGenerator( + PythonFunctionDefinition( + 'a', + [ + PythonFunctionArgument( + 'hello', + PythonArgumentKind.POSITIONAL_ONLY, + None, + 'int', + ), + PythonFunctionArgument( + 'world', + PythonArgumentKind.NORMAL, + '1', + None, + ), + PythonFunctionArgument( + 'something', + PythonArgumentKind.KEYWORD_ONLY, + '\'something\'', + 'str', + ), + PythonFunctionArgument( + 'value', + PythonArgumentKind.KWARGS, + None, + None, + ), + ], + 'bool', + PythonDocstring( + '''A function. + +Very long ... + +:param hello: A parameter. +:type hello: str +:param something: Something. +:param value: The value. +:type value: object + +:raises ValueError: If the value is invalid. + +:return: The return value. +:rtype: list''', + ), + ['decorate(1, 2, 3)'], + ), + allow_html = False, + allow_tables = True, + skip_empty_sections = False, ), '''# Function `a` @@ -2625,7 +2629,7 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), @@ -2638,25 +2642,25 @@ Very long ... 'hello', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'world', PythonArgumentKind.NORMAL, '1', - None + None, ), PythonFunctionArgument( 'something', PythonArgumentKind.KEYWORD_ONLY, '\'something\'', - 'str' + 'str', ), PythonFunctionArgument( 'value', PythonArgumentKind.KWARGS, None, - None + None, ), ], 'bool', @@ -2674,12 +2678,12 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), - ['decorate(1, 2, 3)'] + ['decorate(1, 2, 3)'], ), allow_tables = True, - skip_empty_sections = False + skip_empty_sections = False, ), ( '''# Function `a` @@ -2740,7 +2744,7 @@ Very long ... :return: The return value. :rtype: list''' - ) + ), ), @@ -2753,25 +2757,25 @@ Very long ... 'hello', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'world', PythonArgumentKind.NORMAL, '1', - None + None, ), PythonFunctionArgument( 'something', PythonArgumentKind.KEYWORD_ONLY, '\'something\'', - 'str' + 'str', ), PythonFunctionArgument( 'value', PythonArgumentKind.KWARGS, None, - None + None, ), ], 'bool', @@ -2789,9 +2793,9 @@ Very long ... :raises ValueError: If the value is invalid. :return: The return value. -:rtype: list''' +:rtype: list''', ), - ['decorate(1, 2, 3)'] + ['decorate(1, 2, 3)'], ), PythonDefinitionDocumentationIncludeSections( signature = False, @@ -2801,16 +2805,16 @@ Very long ... examples = False, docstring = False, bases = False, - decorators = False + decorators = False, ), allow_tables = True, - skip_empty_sections = False + skip_empty_sections = False, ), '''# Function `a` A function. -Very long ...''' +Very long ...''', ), @@ -2826,7 +2830,7 @@ Examples -------- >>> A() ->>> A()''' +>>> A()''', ), ['dec', 'ora', 'tor'], [ @@ -2837,12 +2841,12 @@ Examples 'self', PythonArgumentKind.NORMAL, None, - None + None, ), ], None, None, - [] + [], ), PythonFunctionDefinition( 'method', @@ -2851,18 +2855,18 @@ Examples 'self', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'a', PythonArgumentKind.NORMAL, '1', - 'int' - ) + 'int', + ), ], 'str', None, - ['decorator'] + ['decorator'], ), PythonAsyncFunctionDefinition( 'method2', @@ -2871,12 +2875,12 @@ Examples 'self', PythonArgumentKind.NORMAL, None, - None + None, ), ], None, None, - [] + [], ), PythonClassDefinition( 'B', @@ -2891,22 +2895,22 @@ Examples 'self', PythonArgumentKind.NORMAL, None, - None + None, ) ], None, None, - [] - ) - ] - ) - ] + [], + ), + ], + ), + ], ), allow_html = False, allow_tables = True, include_sections = PythonDefinitionDocumentationIncludeSections( - bases = False - ) + bases = False, + ), ), '''# Class `A` @@ -3028,12 +3032,12 @@ Examples -------- >>> A() ->>> A()''' - ) +>>> A()''', + ), ]) def test_PythonDefinitionDocumentationGenerator_generate_documentation( definition_documentation_generator, - expected + expected, ): assert ( definition_documentation_generator.generate_documentation() diff --git a/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py index 9e2c79d..e94a613 100644 --- a/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py @@ -15,7 +15,7 @@ from src.jcloud_docsgen.core.python import PythonDocumentationGenerator from src.jcloud_docsgen.core.python.namespaces import ( PythonModuleNamespace, - PythonPackageNamespace + PythonPackageNamespace, ) import pytest import pathlib @@ -28,9 +28,9 @@ import pathlib ), pathlib.Path( 'tests/unit/core/python/_core/test_project_dirs/pdir_1/docs' - ) + ), ), - [] + [], ), ( PythonDocumentationGenerator( @@ -39,16 +39,16 @@ import pathlib ), pathlib.Path( 'tests/unit/core/python/_core/test_project_dirs/pdir_2/docs' - ) + ), ), [ PythonPackageNamespace( 'pkg', [ PythonModuleNamespace('module') - ] - ) - ] + ], + ), + ], ), ( PythonDocumentationGenerator( @@ -57,7 +57,7 @@ import pathlib ), pathlib.Path( 'tests/unit/core/python/_core/test_project_dirs/pdir_3/docs' - ) + ), ), [ PythonPackageNamespace( @@ -69,17 +69,17 @@ import pathlib [ PythonModuleNamespace( 'module2' - ) - ] - ) - ] - ) - ] + ), + ], + ), + ], + ), + ], ), ]) def test_PythonDocumentationGenerator_collect_modules( python_documentation_generator: PythonDocumentationGenerator, - expected + expected, ): assert python_documentation_generator.namespace() == expected @@ -89,7 +89,7 @@ def test_PythonDocumentationGenerator_collect_modules( ( 'tests/unit/core/python/_core/test_PythonDocume' 'ntationGenerator/test_generate_documentation/' - ) + ), ).iterdir() ]) def test_generate_documentation(dir, expectdir): @@ -103,13 +103,13 @@ def test_generate_documentation(dir, expectdir): ( 'tests/unit/core/python/_core/test_PythonDocume' 'ntationGenerator/test_generate_documentation/' - ) + ), ) / dir / - 'project' - ) + 'project', + ), ), pathlib.Path(str(d)), allow_tables = True, - allow_html = False + allow_html = False, ).generate_documentation() # simplify the tests diff --git a/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py index 92ba600..de6ee92 100644 --- a/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonModuleDocumentationGenerator.py @@ -25,194 +25,192 @@ import pytest ( 'tests/unit/core/python/_core/fil' 'es_with_more_than_one_dot/a.b.c' - ) + ), ), None, InvalidNamespaceError, - 'namespace identifier cannot contain more than one dot: a.b.c' + 'namespace identifier cannot contain more than one dot: a.b.c', ), ( pathlib.Path( ( 'tests/unit/core/python/_core/file' 's_with_more_than_one_dot/a.b.c.d' - ) + ), ), None, InvalidNamespaceError, - 'namespace identifier cannot contain more than one dot: a.b.c.d' + 'namespace identifier cannot contain more than one dot: a.b.c.d', ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files' '_with_more_than_one_dot/a.b.c.d.e' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot cont' 'ain more than one dot: a.b.c.d.e' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_' 'with_more_than_one_dot/a.b.c.d.e.f' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot conta' 'in more than one dot: a.b.c.d.e.f' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_w' 'ith_more_than_one_dot/a.b.c.d.e.f.g' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot contai' 'n more than one dot: a.b.c.d.e.f.g' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_wi' 'th_more_than_one_dot/a.b.c.d.e.f.g.h' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot contain' ' more than one dot: a.b.c.d.e.f.g.h' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_wit' 'h_more_than_one_dot/a.b.c.d.e.f.g.h.py' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot contain m' 'ore than one dot: a.b.c.d.e.f.g.h.py' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_wi' 'th_more_than_one_dot/a.b.c.d.e.f.g.py' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot contain ' 'more than one dot: a.b.c.d.e.f.g.py' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_w' 'ith_more_than_one_dot/a.b.c.d.e.f.py' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot contain' ' more than one dot: a.b.c.d.e.f.py' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files_' 'with_more_than_one_dot/a.b.c.d.e.py' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot contai' 'n more than one dot: a.b.c.d.e.py' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/files' '_with_more_than_one_dot/a.b.c.d.py' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot conta' 'in more than one dot: a.b.c.d.py' - ) + ), ), ( pathlib.Path( ( 'tests/unit/core/python/_core/file' 's_with_more_than_one_dot/a.b.c.py' - ) + ), ), None, InvalidNamespaceError, ( 'namespace identifier cannot cont' 'ain more than one dot: a.b.c.py' - ) + ), ), ( pathlib.Path( ( - ( - 'tests/unit/core/python/_core/fil' - 'es_with_more_than_one_dot/a.b.py' - ) - ) + 'tests/unit/core/python/_core/fil' + 'es_with_more_than_one_dot/a.b.py' + ), ), None, InvalidNamespaceError, - 'namespace identifier cannot contain more than one dot: a.b.py' + 'namespace identifier cannot contain more than one dot: a.b.py', ), ( pathlib.Path( ( 'tests/unit/core/python/_core/direc' 'tory.with.more.than.one.dot/a.b.py' - ) + ), ), None, InvalidNamespaceError, - 'namespace identifier cannot contain more than one dot: a.b.py' + 'namespace identifier cannot contain more than one dot: a.b.py', ), - ] + ], ) def test_PythonModuleDocumentationGenerator_exceptions( module_path, src_directory, expected_exception, - expected_exception_msg + expected_exception_msg, ): with pytest.raises(expected_exception) as exc_info: PythonModuleDocumentationGenerator(module_path, src_directory) @@ -225,13 +223,13 @@ def test_PythonModuleDocumentationGenerator_exceptions( ( 'tests/unit/core/python/_core/test_pr' 'oject_dirs/pdir_2/src/pkg/module.py' - ) + ), ), pathlib.Path( 'tests/unit/core/python/_core/test_project_dirs/pdir_2/src/' ), allow_tables = True, - allow_html = False + allow_html = False, ), '''# Module `pkg.module` @@ -409,11 +407,11 @@ A dog.''' ( 'tests/unit/core/python/_core/test_pr' 'oject_dirs/pdir_2/src/pkg/module.py' - ) + ), ), None, allow_tables = True, - allow_html = False + allow_html = False, ), '''# Module `module` @@ -591,11 +589,11 @@ A dog.''' ( 'tests/unit/core/python/_core/test_pr' 'oject_dirs/pdir_2/src/pkg/module.py' - ) + ), ), None, allow_tables = True, - allow_html = True + allow_html = True, ), ( '''# Module `module` @@ -761,7 +759,7 @@ Return type: `None`

Docstring

A dog.''' '
' - ) + ), ), ( @@ -770,11 +768,11 @@ Return type: `None` ( 'tests/unit/core/python/_core/test_pr' 'oject_dirs/pdir_2/src/pkg/module.py' - ) + ), ), None, allow_tables = False, - allow_html = True + allow_html = True, ), ( '''# Module `module` @@ -982,7 +980,7 @@ Return type: `None`

Docstring

A ''' 'dog.
' - ) + ), ), ( @@ -991,11 +989,11 @@ Return type: `None` ( 'tests/unit/core/python/_core/test_pr' 'oject_dirs/pdir_2/src/pkg/module.py' - ) + ), ), None, allow_tables = False, - allow_html = False + allow_html = False, ), '''# Module `module` @@ -1211,6 +1209,6 @@ A dog.''' ]) def test_PythonModuleDocumentationGenerator_exceptions( module_documentation_generator, - expected + expected, ): assert module_documentation_generator.generate_documentation() == expected diff --git a/tests/unit/core/python/_core/test__collect_definitions.py b/tests/unit/core/python/_core/test__collect_definitions.py index ad20086..56e3b6e 100644 --- a/tests/unit/core/python/_core/test__collect_definitions.py +++ b/tests/unit/core/python/_core/test__collect_definitions.py @@ -15,11 +15,11 @@ from src.jcloud_docsgen.core.python._core import _collect_definitions from src.jcloud_docsgen.core.python.definitions import ( PythonClassDefinition, - PythonFunctionDefinition + PythonFunctionDefinition, ) from src.jcloud_docsgen.core.python.arguments import ( PythonFunctionArgument, - PythonArgumentKind + PythonArgumentKind, ) from src.jcloud_docsgen.core.python.docstrings import PythonDocstring import pytest @@ -49,20 +49,20 @@ def module(source_code: str) -> ast.Module: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), ], None, None, - [] - ) - ] + [], + ), + ], ), ( module('''def add(a: int | float, b: int | float) -> int | float: @@ -97,18 +97,18 @@ class Something: 'a', PythonArgumentKind.NORMAL, None, - 'int | float' + 'int | float', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - 'int | float' + 'int | float', ), ], 'int | float', PythonDocstring('Adds two numbers.'), - [] + [], ), PythonClassDefinition( 'Something', @@ -123,18 +123,18 @@ class Something: 'self', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'value', PythonArgumentKind.NORMAL, '42', - 'typing.Any' + 'typing.Any', ), ], 'None', None, - [] + [], ), PythonFunctionDefinition( 'value', @@ -143,12 +143,12 @@ class Something: 'self', PythonArgumentKind.NORMAL, None, - None + None, ), ], 'typing.Any', PythonDocstring('The value.'), - ['property'] + ['property'], ), PythonFunctionDefinition( 'get_value', @@ -157,16 +157,16 @@ class Something: 'self', PythonArgumentKind.NORMAL, None, - None + None, ), ], 'typing.Any', PythonDocstring('Returns the value.'), - [] + [], ), - ] - ) - ] + ], + ), + ], ), ( module('''from src.jcloud_docsgen.core.python import ( @@ -244,13 +244,13 @@ def test_PythonDocumentationGenerator_collect_modules( 'project_directory', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'docs_directory', PythonArgumentKind.NORMAL, None, - None + None, ) ], None, @@ -263,8 +263,8 @@ def test_PythonDocumentationGenerator_collect_modules( '''(pathlib.Path('tests/'), 1), (1, pathlib''' '''.Path('tests/')), (1, pathlib.Path('test''' '''s')), (None, pathlib.Path('tests'))])''' - ) - ] + ), + ], ), PythonFunctionDefinition( 'test_PythonDocumentationGenerator_collect_modules', @@ -273,13 +273,13 @@ def test_PythonDocumentationGenerator_collect_modules( 'python_documentation_generator', PythonArgumentKind.NORMAL, None, - 'PythonDocumentationGenerator' + 'PythonDocumentationGenerator', ), PythonFunctionArgument( 'expected', PythonArgumentKind.NORMAL, None, - None + None, ) ], None, @@ -301,9 +301,9 @@ def test_PythonDocumentationGenerator_collect_modules( '''r_3/docs')), [PythonPackageNamespace('pkg', [Python''' '''ModuleNamespace(\'module'), PythonPackageNamespace(''' '''\'pkg\', [PythonModuleNamespace(\'module2')])])])])''' - )] - ) - ] + )], + ), + ], ), ( module( @@ -341,33 +341,33 @@ def test_PythonDocumentationGenerator_collect_modules( 'self', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'value', PythonArgumentKind.POSITIONAL_ONLY, None, - 'bool' + 'bool', ), PythonFunctionArgument( 'arg', PythonArgumentKind.NORMAL, None, - None + None, ) ], 'bool', None, - [] - ) - ] - ) - ] - ) - ] - ) - ] - ) + [], + ), + ], + ), + ], + ), + ], + ), + ], + ), ]) def test___collect_definitions(module, expected): assert list(_collect_definitions(module)) == 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 dc52e82..014b4cd 100644 --- a/tests/unit/core/python/_core/test__function_params_info.py +++ b/tests/unit/core/python/_core/test__function_params_info.py @@ -14,17 +14,17 @@ from src.jcloud_docsgen.core.python._core import ( _function_params_info, - _FunctionParamInfo + _FunctionParamInfo, ) from src.jcloud_docsgen.core.python.arguments import ( PythonFunctionArgument, - PythonArgumentKind + PythonArgumentKind, ) import pytest import docstring_parser def docstring_args_list( - docstring: str + docstring: str, ) -> list[docstring_parser.DocstringParam]: ''' Returns the parameter list of a docstring. @@ -42,68 +42,68 @@ def docstring_args_list( ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'int'), ], ':param a: a\n:type a: str', { - 'a': _FunctionParamInfo('int', 'a') + 'a': _FunctionParamInfo('int', 'a'), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), ], ':param a: a\n:type a: str', { - 'a': _FunctionParamInfo('str', 'a') + 'a': _FunctionParamInfo('str', 'a'), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', None), ], ':param a: a\n:type a: str', { 'a': _FunctionParamInfo('str', 'a'), - 'b': _FunctionParamInfo(None, None) + 'b': _FunctionParamInfo(None, None), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'), ], ':param a: a\n:type a: str', { 'a': _FunctionParamInfo('str', 'a'), - 'b': _FunctionParamInfo('int', None) + 'b': _FunctionParamInfo('int', None), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), PythonFunctionArgument('b', PythonArgumentKind.NORMAL, '', 'int'), ], ':param a: a\n:type a: str\n:param b: b\n:type b: str', { 'a': _FunctionParamInfo('str', 'a'), - 'b': _FunctionParamInfo('int', 'b') + 'b': _FunctionParamInfo('int', 'b'), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), ], ':param a: a\n:type a: str\n:param b: b\n:type b: int', { - 'a': _FunctionParamInfo('str', 'a') + 'a': _FunctionParamInfo('str', 'a'), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), ], '', { - 'a': _FunctionParamInfo(None, None) + 'a': _FunctionParamInfo(None, None), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'), ], '', { - 'a': _FunctionParamInfo('str', None) + 'a': _FunctionParamInfo('str', None), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'), ], ':param a:\n:type a: int', { - 'a': _FunctionParamInfo('str', '') + 'a': _FunctionParamInfo('str', ''), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), ], ':param a:\n:type a: int', { - 'a': _FunctionParamInfo('int', '') + 'a': _FunctionParamInfo('int', ''), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', None), ], ':param a: a', { - 'a': _FunctionParamInfo(None, 'a') + 'a': _FunctionParamInfo(None, 'a'), }), ([ PythonFunctionArgument('a', PythonArgumentKind.NORMAL, '', 'str'), ], ':param a: a', { - 'a': _FunctionParamInfo('str', 'a') + 'a': _FunctionParamInfo('str', 'a'), }), ([], ':param a: a\n:type a: str', {}), ([], '', {}), diff --git a/tests/unit/core/python/_core/test__markdown_table.py b/tests/unit/core/python/_core/test__markdown_table.py index 1b41de1..90b49b4 100644 --- a/tests/unit/core/python/_core/test__markdown_table.py +++ b/tests/unit/core/python/_core/test__markdown_table.py @@ -28,7 +28,7 @@ import pytest False, True, '--', - '' + '', ), ( [], @@ -37,7 +37,7 @@ import pytest False, True, '--', - '' + '', ), ( ['a'], @@ -46,7 +46,7 @@ import pytest False, True, '--', - '' + '', ), ( ['a'], @@ -57,7 +57,7 @@ import pytest '--', '''| a | | --- | -| 1 |''' +| 1 |''', ), ( ['a'], @@ -68,7 +68,7 @@ import pytest '--', '''| a | | --- | -| 1 |''' +| 1 |''', ), ( ['a', 'b'], @@ -79,7 +79,7 @@ import pytest '--', '''| a | b | | --- | --- | -| 1 | 2 |''' +| 1 | 2 |''', ), ( ['a', 'b'], @@ -90,7 +90,7 @@ import pytest '--', '''| a | b | | --- | --- | -| 1 | -- |''' +| 1 | -- |''', ), ( ['a', 'b'], @@ -101,7 +101,7 @@ import pytest '--', '''| a | b | | --- | --- | -| -- | -- |''' +| -- | -- |''', ), ( ['a', 'b'], @@ -113,7 +113,7 @@ import pytest '''| a | b | | --- | --- | | 1 | 2 | -| 3 | 4 |''' +| 3 | 4 |''', ), ( ['a'], @@ -124,7 +124,7 @@ import pytest '--', '''| a | | --- | -| line1 line2 |''' +| line1 line2 |''', ), ( ['a'], @@ -135,7 +135,7 @@ import pytest '--', '''| a | | --- | -| line1\nline2 |''' +| line1\nline2 |''', ), ( @@ -145,7 +145,7 @@ import pytest False, True, '--', - '' + '', ), ( [], @@ -154,7 +154,7 @@ import pytest False, True, '--', - '' + '', ), ( ['a'], @@ -163,7 +163,7 @@ import pytest False, True, '--', - '' + '', ), ( ['a'], @@ -172,7 +172,7 @@ import pytest False, True, '--', - '- a: 1' + '- a: 1', ), ( ['a'], @@ -181,7 +181,7 @@ import pytest False, True, '--', - '- a: 1' + '- a: 1', ), ( ['a', 'b'], @@ -192,7 +192,7 @@ import pytest '--', '''- a: 1 - b: 2''' + b: 2''', ), ( ['a', 'b'], @@ -203,7 +203,7 @@ import pytest '--', '''- a: 1 - b: --''' + b: --''', ), ( ['a', 'b'], @@ -214,7 +214,7 @@ import pytest '--', '''- a: -- - b: --''' + b: --''', ), ( ['a', 'b'], @@ -229,7 +229,7 @@ import pytest - a: 3 - b: 4''' + b: 4''', ), ( ['a'], @@ -238,7 +238,7 @@ import pytest False, True, '--', - '- a: line1 line2' + '- a: line1 line2', ), ( ['a'], @@ -247,9 +247,9 @@ import pytest False, False, '--', - '- a: line1\nline2' - ) - ] + '- a: line1\nline2', + ), + ], ) def test__markdown_table( header, @@ -258,7 +258,7 @@ def test__markdown_table( force_row_lengths, one_line_values, missing_value, - expected + expected, ): assert _markdown_table( header, @@ -266,7 +266,7 @@ def test__markdown_table( allow_markdown_table = allow_markdown_table, force_row_lengths = force_row_lengths, one_line_values = one_line_values, - missing_value = missing_value + missing_value = missing_value, ) == expected @pytest.mark.parametrize( @@ -283,7 +283,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 1 value, got 2' + 'expected 1 value, got 2', ), ( ['a'], @@ -293,7 +293,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 1 value, got 3' + 'expected 1 value, got 3', ), ( ['a'], @@ -303,7 +303,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 1 value, got 0' + 'expected 1 value, got 0', ), ( ['a', 'b'], @@ -313,7 +313,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 2 values, got 0' + 'expected 2 values, got 0', ), ( ['a', 'b'], @@ -323,7 +323,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 2 values, got 1' + 'expected 2 values, got 1', ), ( ['a', 'b'], @@ -333,7 +333,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 2 values, got 3' + 'expected 2 values, got 3', ), ( @@ -344,7 +344,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 1 value, got 2' + 'expected 1 value, got 2', ), ( ['a'], @@ -354,7 +354,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 1 value, got 3' + 'expected 1 value, got 3', ), ( ['a'], @@ -364,7 +364,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 1 value, got 0' + 'expected 1 value, got 0', ), ( ['a', 'b'], @@ -374,7 +374,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 2 values, got 0' + 'expected 2 values, got 0', ), ( ['a', 'b'], @@ -384,7 +384,7 @@ def test__markdown_table( True, '--', ValueError, - 'expected 2 values, got 1' + 'expected 2 values, got 1', ), ( ['a', 'b'], @@ -394,9 +394,9 @@ def test__markdown_table( True, '--', ValueError, - 'expected 2 values, got 3' - ) - ] + 'expected 2 values, got 3', + ), + ], ) def test__markdown_table_exceptions( header, @@ -406,7 +406,7 @@ def test__markdown_table_exceptions( one_line_values, missing_value, expected_exception, - expected_exception_msg + expected_exception_msg, ): with pytest.raises(expected_exception) as exc_info: _markdown_table( @@ -415,6 +415,6 @@ def test__markdown_table_exceptions( allow_markdown_table = allow_markdown_table, force_row_lengths = force_row_lengths, one_line_values = one_line_values, - missing_value = missing_value + missing_value = missing_value, ) assert str(exc_info.value) == expected_exception_msg 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 7448647..b586e4b 100644 --- a/tests/unit/core/python/_core/test__signature_argument_list.py +++ b/tests/unit/core/python/_core/test__signature_argument_list.py @@ -15,7 +15,7 @@ from src.jcloud_docsgen.core.python._core import _signature_argument_list from src.jcloud_docsgen.core.python.arguments import ( PythonFunctionArgument, - PythonArgumentKind + PythonArgumentKind, ) import pytest @@ -25,93 +25,93 @@ import pytest 'a', PythonArgumentKind.NORMAL, None, - None - ) + None, + ), ], ['a']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None - ) + None, + ), ], ['a', '/']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None - ) + None, + ), ], ['a', '/', 'b']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None - ) + None, + ), ], ['a', '/', 'b', '*', 'c']), ([ PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None - ) + None, + ), ], ['b', '*', 'c']), ([ PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None - ) + None, + ), ], ['*', 'c']), ([ PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None - ) + None, + ), ], ['b', '/', '*', 'c']), ([ PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ) ], ['*args']), ([ @@ -119,164 +119,164 @@ import pytest 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None - ) + None, + ), ], ['a', '*args']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None - ) + None, + ), ], ['a', '/', '*args']), ([ PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, None, - None - ) + None, + ), ], ['*args', 'a']), ([ PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['*args', '**kwargs']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['a', '/', '*args', '**kwargs']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['a', '*args', '**kwargs']), ([ PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['*args', 'a', '**kwargs']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['*', 'a', '**kwargs']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['a', '**kwargs']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) + None, + ), ], ['a', '/', '**kwargs']), ([ PythonFunctionArgument( 'a', PythonArgumentKind.NORMAL, '1', - 'int' + 'int', ), ], ['a: int = 1']), ]) diff --git a/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py b/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py index 553f052..2b1a8b8 100644 --- a/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py +++ b/tests/unit/core/python/arguments/test_PythonASTArgumentsListParser.py @@ -15,7 +15,7 @@ from src.jcloud_docsgen.core.python.arguments import ( PythonASTArgumentsListParser, PythonFunctionArgument, - PythonArgumentKind + PythonArgumentKind, ) import pytest import ast @@ -41,9 +41,9 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: str'), @@ -52,9 +52,9 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'str' - ) - ] + 'str', + ), + ], ), ( argument_list('a: str | int'), @@ -63,9 +63,9 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'str | int' - ) - ] + 'str | int', + ), + ], ), ( argument_list('a: str, b'), @@ -74,15 +74,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'str' + 'str', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: str, b: int'), @@ -91,15 +91,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'str' + 'str', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - 'int' - ) - ] + 'int', + ), + ], ), ( argument_list('a, b: int'), @@ -108,15 +108,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - 'int' - ) - ] + 'int', + ), + ], ), ( argument_list('a, b, *args'), @@ -125,21 +125,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: int, b, *args'), @@ -148,21 +148,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a, b: str, *args'), @@ -171,21 +171,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - 'str' + 'str', ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: int, b: str, *args'), @@ -194,21 +194,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - 'str' + 'str', ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: int, b: str, *args: float'), @@ -217,21 +217,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - 'str' + 'str', ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - 'float' - ) - ] + 'float', + ), + ], ), ( argument_list('a: int, b, *args: float'), @@ -240,21 +240,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - 'float' - ) - ] + 'float', + ), + ], ), ( argument_list('a: int, *args: float'), @@ -263,15 +263,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - 'float' - ) - ] + 'float', + ), + ], ), ( argument_list('a: int, /, **kwargs'), @@ -280,15 +280,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: int, **kwargs: str'), @@ -297,15 +297,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - 'int' + 'int', ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - 'str' - ) - ] + 'str', + ), + ], ), ( argument_list('a: int, /, b, **kwargs'), @@ -314,21 +314,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None - ) - ] + None, + ), + ], ), ( argument_list('a: int, /, b'), @@ -337,15 +337,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), - ] + ], ), ( argument_list('a: int, /, b, *, c'), @@ -354,21 +354,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), - ] + ], ), ( argument_list('a, b, *, c'), @@ -377,21 +377,21 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), - ] + ], ), ( argument_list('a, b, *args, c'), @@ -400,27 +400,27 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), - ] + ], ), ( argument_list('a, b, *args, c, **kwargs'), @@ -429,33 +429,33 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b, /, *, c, **kwargs'), @@ -464,27 +464,27 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b, /, c, *, d, **kwargs'), @@ -493,231 +493,231 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.NORMAL, None, - None + None, ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list( ( 'a: str, b: int, /, c: float, d: list,' ' *, e: tuple, f: dict, **kwargs: set' - ) + ), ), [ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'str' + 'str', ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'c', PythonArgumentKind.NORMAL, None, - 'float' + 'float', ), PythonFunctionArgument( 'd', PythonArgumentKind.NORMAL, None, - 'list' + 'list', ), PythonFunctionArgument( 'e', PythonArgumentKind.KEYWORD_ONLY, None, - 'tuple' + 'tuple', ), PythonFunctionArgument( 'f', PythonArgumentKind.KEYWORD_ONLY, None, - 'dict' + 'dict', ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - 'set' + 'set', ), - ] + ], ), ( argument_list( ( 'a: str, b: int, /, c: float, d: list, *arg' 's: bytes, e: tuple, f: dict, **kwargs: set' - ) + ), ), [ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'str' + 'str', ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'c', PythonArgumentKind.NORMAL, None, - 'float' + 'float', ), PythonFunctionArgument( 'd', PythonArgumentKind.NORMAL, None, - 'list' + 'list', ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - 'bytes' + 'bytes', ), PythonFunctionArgument( 'e', PythonArgumentKind.KEYWORD_ONLY, None, - 'tuple' + 'tuple', ), PythonFunctionArgument( 'f', PythonArgumentKind.KEYWORD_ONLY, None, - 'dict' + 'dict', ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - 'set' + 'set', ), - ] + ], ), ( argument_list( ( 'a: str, b: int, /, *args: bytes, ' 'c: tuple, d: dict, **kwargs: set' - ) + ), ), [ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'str' + 'str', ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - 'bytes' + 'bytes', ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - 'tuple' + 'tuple', ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, None, - 'dict' + 'dict', ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - 'set' + 'set', ), - ] + ], ), ( argument_list( - 'a = 1, b = \'a\', /, *args, c = None, d = True, **kwargs' + 'a = 1, b = \'a\', /, *args, c = None, d = True, **kwargs', ), [ PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, '1', - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, '\'a\'', - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, 'None', - None + None, ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, 'True', - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b = \'a\', /, *args, c = None, d = True, **kwargs'), @@ -726,19 +726,19 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, '\'a\'', - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', @@ -750,15 +750,15 @@ def argument_list(argument_list: str) -> ast.arguments: 'd', PythonArgumentKind.KEYWORD_ONLY, 'True', - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b , /, *args, c = None, d = True, **kwargs'), @@ -767,39 +767,39 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, 'None', - None + None, ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, 'True', - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b , /, *args, c, d = True, **kwargs'), @@ -808,39 +808,39 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, 'True', - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b , /, *args, c, d, **kwargs'), @@ -849,39 +849,39 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a, b , /, *args, c = None, d, **kwargs'), [ @@ -889,39 +889,39 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'b', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), PythonFunctionArgument( 'args', PythonArgumentKind.VARARG, None, - None + None, ), PythonFunctionArgument( 'c', PythonArgumentKind.KEYWORD_ONLY, 'None', - None + None, ), PythonFunctionArgument( 'd', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), PythonFunctionArgument( 'kwargs', PythonArgumentKind.KWARGS, None, - None + None, ), - ] + ], ), ( argument_list('a = 1'), @@ -930,14 +930,14 @@ def argument_list(argument_list: str) -> ast.arguments: 'a', PythonArgumentKind.NORMAL, '1', - None - ) - ] + None, + ), + ], ), ]) def test_PythonASTArgumentsListParser_to_argument_list( ast_arguments_list, - expected + expected, ): assert PythonASTArgumentsListParser( ast_arguments_list diff --git a/tests/unit/core/python/arguments/test_PythonFunctionArgument.py b/tests/unit/core/python/arguments/test_PythonFunctionArgument.py index 2e30b25..ec6747d 100644 --- a/tests/unit/core/python/arguments/test_PythonFunctionArgument.py +++ b/tests/unit/core/python/arguments/test_PythonFunctionArgument.py @@ -14,12 +14,12 @@ from src.jcloud_docsgen.core.python.arguments import ( PythonFunctionArgument, - PythonArgumentKind + PythonArgumentKind, ) from src.jcloud_docsgen.exceptions import ( InvalidPythonIdentifierError, InvalidPythonAnnotationError, - PythonArgumentStructureError + PythonArgumentStructureError, ) import pytest @@ -32,7 +32,7 @@ import pytest None, None, TypeError, - 'expected \'str\', got \'NoneType\'' + 'expected \'str\', got \'NoneType\'', ), ( 1, @@ -40,7 +40,7 @@ import pytest None, None, TypeError, - 'expected \'str\', got \'int\'' + 'expected \'str\', got \'int\'', ), ( 42, @@ -48,7 +48,7 @@ import pytest None, None, TypeError, - 'expected \'str\', got \'int\'' + 'expected \'str\', got \'int\'', ), ( 4.2, @@ -56,7 +56,7 @@ import pytest None, None, TypeError, - 'expected \'str\', got \'float\'' + 'expected \'str\', got \'float\'', ), ( 4.2, @@ -64,7 +64,7 @@ import pytest None, None, TypeError, - 'expected \'str\', got \'float\'' + 'expected \'str\', got \'float\'', ), ( 'a', @@ -72,7 +72,7 @@ import pytest 1, None, TypeError, - 'expected either \'str\' or \'NoneType\', got \'int\'' + 'expected either \'str\' or \'NoneType\', got \'int\'', ), ( 'a', @@ -80,7 +80,7 @@ import pytest None, 1, TypeError, - 'expected either \'str\' or \'NoneType\', got \'int\'' + 'expected either \'str\' or \'NoneType\', got \'int\'', ), ( 'a', @@ -88,7 +88,7 @@ import pytest None, None, TypeError, - 'expected \'PythonArgumentKind\', got \'int\'' + 'expected \'PythonArgumentKind\', got \'int\'', ), ( 'a', @@ -96,7 +96,7 @@ import pytest None, '', InvalidPythonAnnotationError, - 'invalid annotation' + 'invalid annotation', ), ( '', @@ -104,7 +104,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier' + 'invalid identifier', ), ( '.', @@ -112,7 +112,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: .' + 'invalid identifier: .', ), ( '#', @@ -120,7 +120,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: #' + 'invalid identifier: #', ), ( '1a', @@ -128,7 +128,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: 1a' + 'invalid identifier: 1a', ), ( '1_', @@ -136,7 +136,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: 1_' + 'invalid identifier: 1_', ), ( '1,', @@ -144,7 +144,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: 1,' + 'invalid identifier: 1,', ), ( ',', @@ -152,7 +152,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: ,' + 'invalid identifier: ,', ), ( ':', @@ -160,7 +160,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: :' + 'invalid identifier: :', ), ( '-', @@ -168,7 +168,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: -' + 'invalid identifier: -', ), ( ';', @@ -176,7 +176,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: ;' + 'invalid identifier: ;', ), ( '|', @@ -184,7 +184,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: |' + 'invalid identifier: |', ), ( '<', @@ -192,7 +192,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: <' + 'invalid identifier: <', ), ( '>', @@ -200,7 +200,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: >' + 'invalid identifier: >', ), ( 'a,', @@ -208,7 +208,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a,' + 'invalid identifier: a,', ), ( ',a', @@ -216,7 +216,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: ,a' + 'invalid identifier: ,a', ), ( 'a:', @@ -224,7 +224,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a:' + 'invalid identifier: a:', ), ( ':a', @@ -232,7 +232,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: :a' + 'invalid identifier: :a', ), ( 'a-', @@ -240,7 +240,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a-' + 'invalid identifier: a-', ), ( '-a', @@ -248,7 +248,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: -a' + 'invalid identifier: -a', ), ( 'a;', @@ -256,7 +256,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a;' + 'invalid identifier: a;', ), ( ';a', @@ -264,7 +264,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: ;a' + 'invalid identifier: ;a', ), ( 'a|', @@ -272,7 +272,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a|' + 'invalid identifier: a|', ), ( '|a', @@ -280,7 +280,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: |a' + 'invalid identifier: |a', ), ( 'a<', @@ -288,7 +288,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a<' + 'invalid identifier: a<', ), ( '', @@ -304,7 +304,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: a>' + 'invalid identifier: a>', ), ( '>a', @@ -312,7 +312,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: >a' + 'invalid identifier: >a', ), ( 'class', @@ -320,7 +320,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: class' + 'invalid identifier: class', ), ( 'def', @@ -328,7 +328,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: def' + 'invalid identifier: def', ), ( 'lambda', @@ -336,7 +336,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: lambda' + 'invalid identifier: lambda', ), ( 'None', @@ -344,7 +344,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: None' + 'invalid identifier: None', ), ( 'True', @@ -352,7 +352,7 @@ import pytest None, None, InvalidPythonIdentifierError, - 'invalid identifier: True' + 'invalid identifier: True', ), ( 'a', @@ -360,7 +360,7 @@ import pytest '1', None, PythonArgumentStructureError, - '* or ** arguments cannot have default values: *a = 1' + '* or ** arguments cannot have default values: *a = 1', ), ( 'a', @@ -368,9 +368,9 @@ import pytest '1', None, PythonArgumentStructureError, - '* or ** arguments cannot have default values: **a = 1' + '* or ** arguments cannot have default values: **a = 1', ), - ] + ], ) def test_PythonFunctionArgument_exceptions( name, @@ -378,7 +378,7 @@ def test_PythonFunctionArgument_exceptions( default, annotation, expected_exception, - expected_exception_msg + expected_exception_msg, ): with pytest.raises(expected_exception) as exc_info: PythonFunctionArgument(name, kind, default, annotation) @@ -459,18 +459,18 @@ def test_PythonFunctionArgument_asterik(name, kind, annotation): 'a', PythonArgumentKind.NORMAL, None, - None + None, ), - 'a' + 'a', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.NORMAL, '1', - None + None, ), - 'a = 1' + 'a = 1', ), ( PythonFunctionArgument( @@ -479,124 +479,124 @@ def test_PythonFunctionArgument_asterik(name, kind, annotation): None, 'int' ), - 'a: int' + 'a: int', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.NORMAL, '1', - 'int' + 'int', ), - 'a: int = 1' + 'a: int = 1', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - None + None, ), - 'a' + 'a', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, '1', - None + None, ), - 'a = 1' + 'a = 1', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, None, - 'int' + 'int', ), - 'a: int' + 'a: int', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.POSITIONAL_ONLY, '1', - 'int' + 'int', ), - 'a: int = 1' + 'a: int = 1', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, None, - None + None, ), - 'a' + 'a', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, '1', - None + None, ), - 'a = 1' + 'a = 1', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, None, - 'int' + 'int', ), - 'a: int' + 'a: int', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.KEYWORD_ONLY, '1', - 'int' + 'int', ), - 'a: int = 1' + 'a: int = 1', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.VARARG, None, - None + None, ), - '*a' + '*a', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.VARARG, None, - 'int' + 'int', ), - '*a: int' + '*a: int', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.KWARGS, None, - None + None, ), - '**a' + '**a', ), ( PythonFunctionArgument( 'a', PythonArgumentKind.KWARGS, None, - 'int' + 'int', ), - '**a: int' + '**a: int', ), ]) def test_PythonFunctionArgument_signature_repr(argument, expected): diff --git a/tests/unit/core/python/definitions/test_PythonClassDefinition.py b/tests/unit/core/python/definitions/test_PythonClassDefinition.py index 2d94b84..6bd3c51 100644 --- a/tests/unit/core/python/definitions/test_PythonClassDefinition.py +++ b/tests/unit/core/python/definitions/test_PythonClassDefinition.py @@ -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<', ), ( '', @@ -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): diff --git a/tests/unit/core/python/definitions/test_PythonDefinition.py b/tests/unit/core/python/definitions/test_PythonDefinition.py index cb05aec..57efca3 100644 --- a/tests/unit/core/python/definitions/test_PythonDefinition.py +++ b/tests/unit/core/python/definitions/test_PythonDefinition.py @@ -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<', ), ( '', 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): diff --git a/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py b/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py index 09b67a5..c119ecb 100644 --- a/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py +++ b/tests/unit/core/python/definitions/test_PythonFunctionDefinition.py @@ -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<', ), ( '', @@ -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): diff --git a/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py b/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py index c8f873b..e8a5af9 100644 --- a/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py +++ b/tests/unit/core/python/namespaces/test_PythonPackageNamespace.py @@ -14,12 +14,12 @@ from src.jcloud_docsgen.core.python.namespaces import ( PythonPackageNamespace, - PythonModuleNamespace + PythonModuleNamespace, ) import pytest from src.jcloud_docsgen.exceptions import ( NamespaceNotFoundError, - InvalidNamespaceError + InvalidNamespaceError, ) class StrSubclass(str): ... @@ -28,23 +28,23 @@ class StrSubclass(str): ... ( PythonPackageNamespace( 'a', - [] + [], ), - 'a' + 'a', ), ( PythonPackageNamespace( '1', - [] + [], ), - '1' + '1', ), ( PythonPackageNamespace( StrSubclass('a'), - [] + [], ), - StrSubclass('a') + StrSubclass('a'), ), ]) def test_PythonPackageNamespace_name_attribute(namespace, expected_name): @@ -52,7 +52,7 @@ def test_PythonPackageNamespace_name_attribute(namespace, expected_name): namespace_b = PythonModuleNamespace('b') namespace_a = PythonPackageNamespace('a', [ - namespace_b + namespace_b, ]) namespace_c = PythonModuleNamespace('c') namespace_k = PythonModuleNamespace('k') @@ -68,47 +68,47 @@ namespace_d = PythonPackageNamespace('d', [namespace_e]) ( PythonPackageNamespace( 'name', - [namespace_a, namespace_c] + [namespace_a, namespace_c], ), ['c'], - namespace_c + namespace_c, ), ( PythonPackageNamespace( 'name', - [namespace_a, namespace_c] + [namespace_a, namespace_c], ), ['a'], - namespace_a + namespace_a, ), ( PythonPackageNamespace( 'name', - [namespace_a, namespace_c] + [namespace_a, namespace_c], ), ['a', 'b'], - namespace_b + namespace_b, ), ( namespace_d, ['e', 'f', 'g', 'h', 'i'], - namespace_i + namespace_i, ), ( namespace_d, ['e', 'f', 'g', 'h', 'i', 'j'], - namespace_j + namespace_j, ), ( namespace_d, ['e', 'f', 'g', 'h', 'i', 'j', 'k'], - namespace_k + namespace_k, ), ]) def test_PythonPackageNamespace_namespace( namespace: PythonPackageNamespace, sub_namespaces, - expected + expected, ): assert namespace.namespace(sub_namespaces) == expected @@ -119,39 +119,39 @@ def test_PythonPackageNamespace_namespace( namespace_a, ['c'], NamespaceNotFoundError, - 'no such namespace: c' + 'no such namespace: c', ), ( namespace_h, ['i', 'k'], NamespaceNotFoundError, - 'no such namespace: k' + 'no such namespace: k', ), ( namespace_a, ['b', ''], InvalidNamespaceError, - 'invalid namespace' + 'invalid namespace', ), ( namespace_a, ['', 'b'], InvalidNamespaceError, - 'invalid namespace' + 'invalid namespace', ), ( namespace_a, ['b', '', 'b'], InvalidNamespaceError, - 'invalid namespace' + 'invalid namespace', ), - ] + ], ) def test_PythonPackageNamespace_namespace_exceptions( namespace, sub_namespaces, expected_exception, - expected_exception_msg + expected_exception_msg, ): with pytest.raises(expected_exception) as exc_info: namespace.namespace(sub_namespaces) @@ -161,9 +161,9 @@ def test_PythonPackageNamespace_namespace_exceptions( ( PythonPackageNamespace( 'a', - [PythonModuleNamespace('b')] + [PythonModuleNamespace('b')], ), - {'b': 'b'} + {'b': 'b'}, ), ( PythonPackageNamespace( @@ -172,19 +172,19 @@ def test_PythonPackageNamespace_namespace_exceptions( PythonModuleNamespace('b'), PythonPackageNamespace( 'c', - [PythonModuleNamespace('d')] - ) - ] + [PythonModuleNamespace('d')], + ), + ], ), { 'b': 'b', - 'c': {'d': 'd'} - } + 'c': {'d': 'd'}, + }, ), ( PythonPackageNamespace('a', []), - {} - ) + {}, + ), ]) def test_PythonPackageNamespace_sub_namespace_names(namespace, expected): assert namespace.sub_namespace_names() == expected @@ -193,13 +193,13 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected): ( PythonPackageNamespace( 'a', - [PythonModuleNamespace('b')] + [PythonModuleNamespace('b')], ), PythonPackageNamespace( 'a', - [PythonModuleNamespace('b')] + [PythonModuleNamespace('b')], ), - True + True, ), ( PythonPackageNamespace( @@ -208,9 +208,9 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected): PythonModuleNamespace('b'), PythonPackageNamespace( 'c', - [PythonModuleNamespace('d')] - ) - ] + [PythonModuleNamespace('d')], + ), + ], ), PythonPackageNamespace( 'a', @@ -218,21 +218,21 @@ def test_PythonPackageNamespace_sub_namespace_names(namespace, expected): PythonModuleNamespace('b'), PythonPackageNamespace( 'c', - [PythonModuleNamespace('d')] - ) - ] + [PythonModuleNamespace('d')], + ), + ], ), - True + True, ), ( PythonPackageNamespace('a', []), PythonPackageNamespace('a', []), - True + True, ), ( PythonPackageNamespace('a', []), PythonPackageNamespace('b', []), - False + False, ), ]) def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected): @@ -242,19 +242,19 @@ def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected): @pytest.mark.parametrize('namespace,expected', [ ( PythonPackageNamespace('a', []), - 'PythonPackageNamespace(\'a\', [])' + 'PythonPackageNamespace(\'a\', [])', ), ( PythonPackageNamespace('1', []), - 'PythonPackageNamespace(\'1\', [])' + 'PythonPackageNamespace(\'1\', [])', ), ( PythonPackageNamespace(StrSubclass('a'), []), - 'PythonPackageNamespace(\'a\', [])' + 'PythonPackageNamespace(\'a\', [])', ), ( namespace_a, - 'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])' + 'PythonPackageNamespace(\'a\', [PythonModuleNamespace(\'b\')])', ), ( namespace_d, @@ -264,8 +264,8 @@ def test_PythonPackageNamespace___eq__(namespace1, namespace2, expected): 'geNamespace(\'g\', [PythonPackageNamespace(\'h\', [P' 'ythonPackageNamespace(\'i\', [PythonPackageNamespace' '(\'j\', [PythonModuleNamespace(\'k\')])])])])])])])' - ) - ) + ), + ), ]) def test_PythonPackageNamespace_string_representation(namespace, expected): assert repr(namespace) == expected @@ -276,14 +276,14 @@ def test_PythonPackageNamespace_string_representation(namespace, expected): PythonModuleNamespace('b'), PythonPackageNamespace( 'a', - [PythonModuleNamespace('b')] - ) - ) + [PythonModuleNamespace('b')], + ), + ), ]) def test_PythonPackageNamespace___getitem__( namespace, new_namespace, - expected + expected, ): namespace.add(new_namespace) assert namespace == expected diff --git a/tests/unit/utils/test_assert_that_is_instance.py b/tests/unit/utils/test_assert_that_is_instance.py index d95fe92..54d69b2 100644 --- a/tests/unit/utils/test_assert_that_is_instance.py +++ b/tests/unit/utils/test_assert_that_is_instance.py @@ -34,33 +34,33 @@ def test_assert_that_is_instance(obj, class_or_tuple): ( 1, str, - 'expected \'str\', got \'int\'' + 'expected \'str\', got \'int\'', ), ( 1, (str,), - 'expected \'str\', got \'int\'' + 'expected \'str\', got \'int\'', ), ( 1, str | float, - 'expected either \'str\' or \'float\', got \'int\'' + 'expected either \'str\' or \'float\', got \'int\'', ), ( 1, str | float | list, - 'expected either \'str\', \'float\' or \'list\', got \'int\'' + 'expected either \'str\', \'float\' or \'list\', got \'int\'', ), ( 1, TestType, - 'expected \'NOT TestType\', got \'int\'' + 'expected \'NOT TestType\', got \'int\'', ), ]) def test_assert_that_is_instance_exceptions( obj, class_or_tuple, - expected_exception_msg + expected_exception_msg, ): with pytest.raises(TypeError) as exc_info: assert_that_is_instance(obj, class_or_tuple) diff --git a/tests/unit/utils/test_human_readable_list.py b/tests/unit/utils/test_human_readable_list.py index f97854d..e2c921b 100644 --- a/tests/unit/utils/test_human_readable_list.py +++ b/tests/unit/utils/test_human_readable_list.py @@ -52,7 +52,7 @@ import pytest [1, 2, 3, 42, 'a', 23], 'and', '\'', - '\'1\', \'2\', \'3\', \'42\', \'a\' and \'23\'' + '\'1\', \'2\', \'3\', \'42\', \'a\' and \'23\'', ), ]) def test_human_readable_list(ls, final_separator, quotation_mark, expected):