File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff 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.
174174For 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+
176184To enable this filtering, configure the `type_check_command ` to output json results as follows:
177185
178186.. code-block ::
You can’t perform that action at this time.
0 commit comments