Skip to content

Commit 5b9705c

Browse files
committed
Deprecate old ignore file (HunterMcGushion#87)
1 parent bc0f257 commit 5b9705c

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ docstr-coverage docstr_coverage -e ".*/test" --skip-magic --skip-init --badge="d
142142

143143
Note that options passed as command line arguments have precedence over options
144144
configured in a config file.
145-
Exception: If a (deprecated) `--docstr-ignore-file` is present and the yml config contains `ignore_patterns`,
146-
a `ValueError` is raised.
145+
146+
#### Ignoring by Regex
147+
In your config files, using `ignore_patterns`, you can specify regex patterns for files names and nodes (methods, ...)
148+
which should be ignored. See config file example above.
147149

148150
#### Overriding by Comments
149151
Note that `docstr-coverage` can not parse

docstr_coverage/cli.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def execute(paths, **kwargs):
301301
raise ValueError(
302302
(
303303
"The docstr-coverage configuration file {} contains ignore_patterns,"
304-
" and at the same time an ignore file {} was found."
304+
" and at the same time a (deprecated) ignore file {} was found."
305305
" Ignore patterns must be specified in only one location at a time."
306306
).format(kwargs["config_file"], kwargs["ignore_names_file"])
307307
)
@@ -369,7 +369,19 @@ def _deprecation_alerts(kwargs):
369369
"Using deprecated --{}, should use --{}".format(deprecated_name, new_flag), fg="red"
370370
)
371371
kwargs[name] = kwargs.pop(deprecated_name)
372-
if kwargs.get("docstr-ignore-file") or kwargs.get("ignore_names_file"):
372+
373+
# Deprecated old ignore files
374+
ignore_file_old_casing = kwargs.get("docstr-ignore-file")
375+
ignore_file_new_casing = kwargs.get("ignore_names_file")
376+
377+
def _nondefault_or_existing_file(path):
378+
if path is None:
379+
return False
380+
return os.path.split(path)[-1] != ".docstr_coverage" or os.path.isfile(path)
381+
382+
if _nondefault_or_existing_file(ignore_file_old_casing) or _nondefault_or_existing_file(
383+
ignore_file_new_casing
384+
):
373385
click.secho(
374386
"Using deprecated ignore files."
375387
"We'll keep them supported for a while, "

0 commit comments

Comments
 (0)