mutmut icon indicating copy to clipboard operation
mutmut copied to clipboard

`mutmut show 1` throws `TypeError`

Open l0b0 opened this issue 2 years ago • 7 comments

To reproduce:

  1. Clone https://gitlab.com/victor-engmark/mypy-exercises/
  2. Run mutation tests with mutmut run src/generator/test_all.py
  3. Try to show first mutation with mutmut show 1

Expected result: This should show the first mutation.

Actual result:

Traceback (most recent call last):
  File "/nix/store/fbif83prxzi6g76y6g0nz7c8jxjzp66a-python3.9-mutmut-2.4.0/bin/.mutmut-wrapped", line 9, in <module>
    sys.exit(climain())
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__init__.py", line 882, in wrapper
    f(*args, **kwargs)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__main__.py", line 208, in show
    print(get_unified_diff(id_or_file, dict_synonyms))
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/cache.py", line 203, in get_unified_diff
    return _get_unified_diff(source, filename, mutation_id, dict_synonyms, update_cache)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/cache.py", line 214, in _get_unified_diff
    context = Context(
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__init__.py", line 492, in __init__
    self.dict_synonyms = (dict_synonyms or []) + ['dict']
TypeError: can only concatenate str (not "list") to str

Running mutmut 2.4.0.

l0b0 avatar May 26 '22 06:05 l0b0

Strange. What happens if you change dict_synonyms to JsonDict, dict in setup.cfg?

boxed avatar May 26 '22 16:05 boxed

Doesn't help:

$ git diff
diff --git a/setup.cfg b/setup.cfg
index 78fb226..0a0ac2c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,4 +1,4 @@
 [mutmut]
-dict_synonyms=JsonDict
+dict_synonyms=JsonDict, dict
 paths_to_exclude=generators.py,ide_hints.py,name_reuse.py,test_*.py,type_checking
 runner=pytest --assert=plain --exitfirst
$ mutmut show 1
Traceback (most recent call last):
  File "/nix/store/fbif83prxzi6g76y6g0nz7c8jxjzp66a-python3.9-mutmut-2.4.0/bin/.mutmut-wrapped", line 9, in <module>
    sys.exit(climain())
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__init__.py", line 882, in wrapper
    f(*args, **kwargs)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__main__.py", line 208, in show
    print(get_unified_diff(id_or_file, dict_synonyms))
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/cache.py", line 203, in get_unified_diff
    return _get_unified_diff(source, filename, mutation_id, dict_synonyms, update_cache)
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/cache.py", line 214, in _get_unified_diff
    context = Context(
  File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__init__.py", line 492, in __init__
    self.dict_synonyms = (dict_synonyms or []) + ['dict']
TypeError: can only concatenate str (not "list") to str

(I also tried without the space after the comma.)

It works if I completely remove the dict_synonyms setting.

l0b0 avatar May 29 '22 00:05 l0b0

Still broken.

l0b0 avatar Mar 15 '23 01:03 l0b0

Up, the same for mumut show, mutmut html, mumut junitxml Run on python 3.9

olga-govor avatar Apr 03 '23 13:04 olga-govor

workaround: delete dict_synonyms parameter from configuration at all

olga-govor avatar Apr 04 '23 07:04 olga-govor

Any news on this? Still fails in 2.4.4, both with a list and with a comma-separated string.

l0b0 avatar Dec 20 '23 01:12 l0b0

commenting out this line File "/nix/store/92br825d8l2gfz6mvcd1g6ncdliqmblk-python3-3.9.6-env/lib/python3.9/site-packages/mutmut/__init__.py", line 492, in __init__ self.dict_synonyms = (dict_synonyms or []) + ['dict']

"Fixes" this as well.

zeronwad avatar Mar 12 '24 13:03 zeronwad