Skip to content

Parso error : SyntaxError: invalid syntax', <ErrorLeaf: PythonTokenTypes.OP:'} #252

@MartinThoma

Description

@MartinThoma

When I run mutmut run on PyPDF2

I get:

python -m mutmut run        

- Mutation testing starting -

These are the steps:
1. A full test suite run will be made to make sure we
   can run the tests successfully and we know how long
   it takes (to detect infinite loops for example)
2. Mutants will be generated and checked

Results are stored in .mutmut-cache.
Print found mutants with `mutmut results`.

Legend for output:
🎉 Killed mutants.   The goal is for everything to end up in this bucket.
⏰ Timeout.          Test suite took 10 times as long as the baseline so were killed.
🤔 Suspicious.       Tests took a long time, but not long enough to be fatal.
🙁 Survived.         This means your tests need to be expanded.
🔇 Skipped.          Skipped.

1. Using cached time for baseline tests, to run baseline again delete the cache file
Failed to parse PyPDF2/generic.py. Internal error from parso follows.
----------------------------------
Traceback (most recent call last):
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/parser.py", line 180, in _add_token
    plan = stack[-1].dfa.transitions[transition]
KeyError: ReservedString(})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__init__.py", line 1238, in add_mutations_by_file
    mutations_by_file[filename] = list_mutations(context)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__init__.py", line 678, in list_mutations
    mutate(context)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__init__.py", line 554, in mutate
    result = parse(context.source, error_recovery=False)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/__init__.py", line 58, in parse
    return grammar.parse(code, **kwargs)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/grammar.py", line 156, in parse
    root_node = p.parse(tokens=tokens)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/python/parser.py", line 79, in parse
    return super().parse(tokens)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/parser.py", line 129, in parse
    self._add_token(token)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/parser.py", line 186, in _add_token
    self.error_recovery(token)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/python/parser.py", line 140, in error_recovery
    return super().error_recovery(token)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/parso/parser.py", line 152, in error_recovery
    raise ParserSyntaxError('SyntaxError: invalid syntax', error_leaf)
parso.parser.ParserSyntaxError: ('SyntaxError: invalid syntax', <ErrorLeaf: PythonTokenTypes.OP:'}', (545, 53)>)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/moose/.pyenv/versions/3.10.2/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/moose/.pyenv/versions/3.10.2/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__main__.py", line 490, in <module>
    climain()
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__init__.py", line 882, in wrapper
    f(*args, **kwargs)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__main__.py", line 142, in run
    sys.exit(do_run(argument, paths_to_mutate, disable_mutation_types, enable_mutation_types, runner,
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__main__.py", line 397, in do_run
    parse_run_argument(argument, config, dict_synonyms, mutations_by_file, paths_to_exclude, paths_to_mutate, tests_dirs)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__main__.py", line 425, in parse_run_argument
    add_mutations_by_file(mutations_by_file, filename, dict_synonyms, config)
  File "/home/moose/Github/py-pdf/PyPDF2/venv/lib/python3.10/site-packages/mutmut/__init__.py", line 1242, in add_mutations_by_file
    raise RuntimeError('Failed while creating mutations for {}, for line "{}"'.format(context.filename, context.current_source_line)) from e
RuntimeError: Failed while creating mutations for PyPDF2/generic.py, for line "# Copyright (c) 2006, Mathieu Fenniak"

It is just first line of generic.py (a comment). I have no clue why it fails there. Do you have an idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions