Skip to content

Commit f377984

Browse files
committed
Mention limitations of type checking filtering
1 parent 9bfcc75 commit f377984

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,17 @@ If you only want to mutate lines that are called (according to coverage.py), you
170170
Filter generated mutants with type checker
171171
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172172

173-
When your project is type checked, you can also use it to filter out invalid mutants.
173+
When your project is type checked using `mypy` or `pyrefly`, you can also use it to filter out invalid mutants.
174174
For instance, mutmut mutates `x: str = 'foo'` to `x: str = None` which can easily caught by type checkers.
175175

176+
Using this filter can improve performance and reduce noise, however it can also hide a few relevant mutations:
177+
178+
1. `x: str = None` may not be valid, but if your tests do not detect such a change it indicates that
179+
the value of `x` is not properly tested (even if your type checker would catch this particular modification)
180+
2. In some edge cases with class properties (usually in the `__init__` method), the way `mypy` and `pyrefly` infer types does not work well
181+
with the way mutmut mutates code. Some valid mutations like changing `self.x = 123` to `self.x = None` can
182+
be filtered out, even though the may be valid.
183+
176184
To enable this filtering, configure the `type_check_command` to output json results as follows:
177185

178186
.. code-block::

0 commit comments

Comments
 (0)