Skip to content

Commit e3c1a4c

Browse files
Fix typo in link and adjust documentation for warnings. (#306)
Co-authored-by: Tobias Raabe <[email protected]>
1 parent 1413a62 commit e3c1a4c

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

docs/source/_static/images/warning.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/source/how_to_guides/capture_warnings.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,27 @@ def task_warning(produces):
2424
Running pytask produces
2525

2626
```{image} /_static/images/warning.svg
27+
2728
```
2829

2930
## Controlling warnings
3031

31-
You can use the `filterwarnings` option in `pyproject.toml` to configure pytasks
32-
behavior to warnings. For example, the configuration below will ignore all user warnings
33-
and specific deprecation warnings matching a regex, but will transform all other
34-
warnings into errors.
32+
You can use the `filterwarnings` option in `pyproject.toml` to configure pytask's
33+
behavior when it comes to warnings.
34+
35+
The syntax for specifying warnings filters is the same as in the
36+
[Python standard library](https://docs.python.org/3/library/warnings.html#the-warnings-filter),
37+
i.e., a sequence of fields separated by colons:
38+
39+
```
40+
action:message:category:module:line
41+
```
42+
43+
You can specify a list of such filters. When a warning matches more than one option, the
44+
action for the last matching option is performed.
45+
46+
For example, the configuration below will ignore specific deprecation warnings matching
47+
a regex, all user warnings, and transform all other warnings into errors.
3548

3649
```toml
3750
[tool.pytask.ini_options]
@@ -43,8 +56,10 @@ filterwarnings = [
4356
]
4457
```
4558

46-
When a warning matches more than one option in the list, the action for the last
47-
matching option is performed.
59+
The syntax is explained in more detail in
60+
[this section](https://docs.python.org/3/library/warnings.html#the-warnings-filter) of
61+
the Python documentation and there are also
62+
[more examples](https://docs.python.org/3/library/warnings.html#describing-warning-filters).
4863

4964
## `@pytask.mark.filterwarnings`
5065

src/_pytask/warnings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def __rich_console__(
112112
yield Padding.indent(message, 4)
113113
yield (
114114
"[bold red]♥[/bold red] "
115-
+ "https://pytask-dev.rtdf.io/en/stable/how_to_guides/capture_warnings.html"
115+
+ "https://pytask-dev.rtfd.io/en/stable/how_to_guides/capture_warnings.html"
116116
)
117117

118118

0 commit comments

Comments
 (0)