generated from jCloud/repository-template
style: ensure trailing commas in multi-line statements
This commit is contained in:
30 files changed
+1778
-1774
No files matched your search
+13
-12
@@ -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,
|
||||
)
|
||||
Reference in new issue
Block a user