Skip to content

Commit 3f4b3b4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 96ef52c commit 3f4b3b4

File tree

2 files changed

+47
-36
lines changed

2 files changed

+47
-36
lines changed

lib/ncdata/utils/_dim_indexing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import dask.array as da
55
import numpy as np
6-
76
from ncdata import NcData
87

98

tools/run_doctests.py

Lines changed: 47 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111

1212

1313
def list_modules_recursive(
14-
module_importname: str, include_private: bool = True,
15-
exclude_matches: list[str] = []
14+
module_importname: str,
15+
include_private: bool = True,
16+
exclude_matches: list[str] = [],
1617
):
1718
"""Find all the submodules of a given module.
1819
@@ -45,7 +46,8 @@ def list_modules_recursive(
4546
if ispkg:
4647
module_names.extend(
4748
list_modules_recursive(
48-
submodule_name, include_private=include_private,
49+
submodule_name,
50+
include_private=include_private,
4951
exclude_matches=exclude_matches,
5052
)
5153
)
@@ -61,8 +63,7 @@ def list_modules_recursive(
6163

6264

6365
def list_filepaths_recursive(
64-
file_path: str,
65-
exclude_matches: list[str] = []
66+
file_path: str, exclude_matches: list[str] = []
6667
) -> list[Path]:
6768
"""Expand globs to a list of filepaths.
6869
@@ -71,7 +72,8 @@ def list_filepaths_recursive(
7172
actual_paths: list[Path] = []
7273
segments = file_path.split("/")
7374
i_wilds = [
74-
index for index, segment in enumerate(segments)
75+
index
76+
for index, segment in enumerate(segments)
7577
if any(char in segment for char in "*?[")
7678
]
7779
if len(i_wilds) == 0:
@@ -85,14 +87,17 @@ def list_filepaths_recursive(
8587

8688
# Also apply exclude and private filters to results
8789
result = [
88-
path for path in actual_paths
90+
path
91+
for path in actual_paths
8992
if not any(match in str(path) for match in exclude_matches)
9093
and not path.name.startswith("_")
9194
]
9295
return result
9396

9497

95-
def process_options(opt_str: str, paths_are_modules: bool = True) -> dict[str, str]:
98+
def process_options(
99+
opt_str: str, paths_are_modules: bool = True
100+
) -> dict[str, str]:
96101
"""Convert the "-o/--options" arg into a **kwargs for the doctest function call."""
97102
# Remove all spaces (think they are never needed).
98103
opt_str = opt_str.replace(" ", "")
@@ -132,7 +137,7 @@ def process_options(opt_str: str, paths_are_modules: bool = True) -> dict[str, s
132137

133138
def run_doctest_paths(
134139
paths: list[str],
135-
paths_are_modules:bool = False,
140+
paths_are_modules: bool = False,
136141
recurse_modules: bool = False,
137142
include_private_modules: bool = False,
138143
exclude_matches: list[str] = [],
@@ -170,8 +175,9 @@ def run_doctest_paths(
170175
module_paths = []
171176
for path in paths:
172177
module_paths += list_modules_recursive(
173-
path, include_private=include_private_modules,
174-
exclude_matches=exclude_matches
178+
path,
179+
include_private=include_private_modules,
180+
exclude_matches=exclude_matches,
175181
)
176182
paths = module_paths
177183
else:
@@ -180,8 +186,7 @@ def run_doctest_paths(
180186
filepaths = []
181187
for path in paths:
182188
filepaths += list_filepaths_recursive(
183-
path,
184-
exclude_matches=exclude_matches
189+
path, exclude_matches=exclude_matches
185190
)
186191
paths = filepaths
187192

@@ -235,34 +240,36 @@ def run_doctest_paths(
235240
f" paths tested = {n_paths_tested}",
236241
f" tests completed = {n_total_tests}",
237242
f" errors = {n_total_fails}",
238-
""
243+
"",
239244
]
240245
if n_total_fails > 0:
241246
msgs += ["FAILED."]
242247
else:
243248
msgs += ["OK."]
244249

245-
print('\n'.join(msgs))
250+
print("\n".join(msgs))
246251

247252
return n_total_fails
248253

249254

250-
_help_extra_lines = "\n".join([
251-
"Notes:",
252-
" * file paths support glob patterns '* ? [] **' (** to include subdirectories)",
253-
" * N.B. use ** to include subdirectories",
254-
" * N.B. usually requires quotes, to avoid shell expansion",
255-
" * module paths do *not* support globs",
256-
" * but --recurse includes all submodules",
257-
" * \"--exclude\" patterns are a simple substring to match (not a glob/regexp)",
258-
"",
259-
"Examples:",
260-
" $ run_doctests \"docs/**/*.rst\" # test all document sources",
261-
" $ run_doctests \"docs/user*/**/*.rst\" -e detail # skip filepaths containing key string",
262-
" $ run_doctests -mr mymod # test module + all submodules",
263-
" $ run_doctests -mr mymod.util -e maths -e fun.err # skip module paths with substrings",
264-
" $ run_doctests -mr mymod -o verbose=true # make doctest print each test",
265-
])
255+
_help_extra_lines = "\n".join(
256+
[
257+
"Notes:",
258+
" * file paths support glob patterns '* ? [] **' (** to include subdirectories)",
259+
" * N.B. use ** to include subdirectories",
260+
" * N.B. usually requires quotes, to avoid shell expansion",
261+
" * module paths do *not* support globs",
262+
" * but --recurse includes all submodules",
263+
' * "--exclude" patterns are a simple substring to match (not a glob/regexp)',
264+
"",
265+
"Examples:",
266+
' $ run_doctests "docs/**/*.rst" # test all document sources',
267+
' $ run_doctests "docs/user*/**/*.rst" -e detail # skip filepaths containing key string',
268+
" $ run_doctests -mr mymod # test module + all submodules",
269+
" $ run_doctests -mr mymod.util -e maths -e fun.err # skip module paths with substrings",
270+
" $ run_doctests -mr mymod -o verbose=true # make doctest print each test",
271+
]
272+
)
266273

267274

268275
_parser = argparse.ArgumentParser(
@@ -272,8 +279,10 @@ def run_doctest_paths(
272279
formatter_class=argparse.RawDescriptionHelpFormatter,
273280
)
274281
_parser.add_argument(
275-
"-m", "--module", action="store_true",
276-
help="paths are module paths (xx.yy.zz), instead of filepaths."
282+
"-m",
283+
"--module",
284+
action="store_true",
285+
help="paths are module paths (xx.yy.zz), instead of filepaths.",
277286
)
278287
_parser.add_argument(
279288
"-r",
@@ -299,13 +308,16 @@ def run_doctest_paths(
299308
nargs="?",
300309
help=(
301310
"kwargs (Python) for doctest call"
302-
", e.g. \"raise_on_error=True,optionflags=8\"."
311+
', e.g. "raise_on_error=True,optionflags=8".'
303312
),
304313
type=str,
305314
default="",
306315
)
307316
_parser.add_argument(
308-
"-v", "--verbose", action="store_true", help="show details of each operation."
317+
"-v",
318+
"--verbose",
319+
action="store_true",
320+
help="show details of each operation.",
309321
)
310322
_parser.add_argument(
311323
"-d",

0 commit comments

Comments
 (0)