Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError raised in FORMATTERS[output_format] #269

Closed
peterdemin opened this issue Jul 27, 2018 · 3 comments
Closed

KeyError raised in FORMATTERS[output_format] #269

peterdemin opened this issue Jul 27, 2018 · 3 comments

Comments

@peterdemin
Copy link

After the upgrade to 1.0 the following command stopped working:

$ prospector -Eu django src
Traceback (most recent call last):
  File "/pmc3/TeamCity/Agent1/work/ca50400e99fa6183/.tox/linters/bin/prospector", line 11, in <module>
    load_entry_point('prospector==1.0', 'console_scripts', 'prospector')()
  File "/pmc3/TeamCity/Agent1/work/ca50400e99fa6183/.tox/linters/lib/python3.6/site-packages/prospector/run.py", line 174, in main
    prospector.print_messages()
  File "/pmc3/TeamCity/Agent1/work/ca50400e99fa6183/.tox/linters/lib/python3.6/site-packages/prospector/run.py", line 132, in print_messages
    formatter = FORMATTERS[output_format](self.summary, self.messages, self.config.profile)
KeyError: None

A little investigation:

> /pmc3/Work/deminp/.virtualenvs/CTXP/lib/python3.6/site-packages/prospector/run.py(132)print_messages()
-> formatter = FORMATTERS[output_format](self.summary, self.messages, self.config.profile)
(Pdb) pp locals()
{'output_files': [],
 'output_format': None,
 'output_reports': [(None, [])],
 'report': (None, []),
 'self': <prospector.run.Prospector object at 0x7f4d41826668>}
(Pdb) self.summary
{'started': datetime.datetime(2018, 7, 27, 16, 40, 10, 208860), 'libraries': ['django'], 'strictness': None, 'profiles': 'default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings', 'tools': ['dodgy', 'mccabe', 'pep8', 'profile-validator', 'pyflakes', 'pylint'], 'message_count': 1, 'completed': datetime.datetime(2018, 7, 27, 16, 40, 15, 453625), 'time_taken': '5.24', 'formatter': None}
(Pdb) self.messages
[pylint-failure]
(Pdb) ll
126         def print_messages(self):
127             output_reports = self.config.get_output_report()
128
129             for report in output_reports:
130                 output_format, output_files = report
131                 self.summary['formatter'] = output_format
132 B->             formatter = FORMATTERS[output_format](self.summary, self.messages, self.config.profile)
133                 if not output_files:
134                     self.write_to(formatter, sys.stdout)
135                 for output_file in output_files:
136                     with open(output_file, 'w+') as target:
137                         self.write_to(formatter, target)
(Pdb) pp self.config.__dict__
{'arguments': {'checkpath': ['src']},
 'config': <Configuration(output_format=None, full_pep8=None, direct_tool_stdout=False, ignore_paths=[], path=None, ignore_patterns=[], loquacious_pylint=False, with_tools=[], without_tools=[], uses=['django'], include_tool_stdout=False, pylint_config_file=None, tools=None, summary_only=False, blending=True, test_warnings=None, show_profile=False, no_external_config=True, member_warnings=None, zero_exit=False, profile_path=['src', '/pmc3/Work/deminp/.virtualenvs/CTXP/lib/python3.6/site-packages/prospector/profiles/profiles'], absolute_paths=False, no_style_warnings=None, profiles=[], strictness=None, messages_only=False, autodetect=True, common_plugin=True, doc_warnings=None, die_on_tool_error=False, max_line_length=None)>,
 'configured_by': {'dodgy': None,
                   'mccabe': None,
                   'pep8': None,
                   'profile-validator': None,
                   'pyflakes': None,
                   'pylint': None},
 'explicit_file_mode': False,
 'ignores': [re.compile('^docs?/'),
             re.compile('^tests?/?'),
             re.compile('/tests?(/|$)'),
             re.compile('(^|/)test_[_a-zA-Z0-9]+.py$'),
             re.compile('(^|/)[_a-zA-Z0-9]+_tests?.py$'),
             re.compile('(^|/)tests?.py'),
             re.compile('^setup.py$'),
             re.compile('(^|/)\\..+'),
             re.compile('(^|/)(south_)?migrations(/|$)')],
 'libraries': ['django'],
 'messages': [],
 'paths': ['src'],
 'profile': <prospector.profiles.profile.ProspectorProfile object at 0x7f4d497fa710>,
 'strictness': None,
 'tools_to_run': ['dodgy',
                  'mccabe',
                  'pep8',
                  'profile-validator',
                  'pyflakes',
                  'pylint'],
 'workdir': 'src'}

The error appears stable, please let me know what can be helpful in reproduction/testing.

@chocoelho
Copy link
Contributor

@peterdemin thanks reporting it. This is being fixed in #262 which contains fixes for two related issues, one of them is that prospector is behaving in different ways depending on the path pointed to and also fixing how default output_report entries are managed if there's any issue in it. After merging this PR and landscapeio/pylint-common#10 we can then release a fixed version of prospector.

@jbaiter
Copy link

jbaiter commented Jul 30, 2018

I'm getting this when running prospectorwithout any arguments on my Flask project:

$ pipenv run prospector
Loading .env environment variables...
/home/jbaiter/.envs/nerkenner-f5Z1Q35w/lib/python3.7/site-packages/pycodestyle.py:113: FutureWarning: Possible nested set at position 1
  EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]')
Traceback (most recent call last):
  File "/home/jbaiter/.envs/nerkenner-f5Z1Q35w/bin/prospector", line 11, in <module>
    sys.exit(main())
  File "/home/jbaiter/.envs/nerkenner-f5Z1Q35w/lib/python3.7/site-packages/prospector/run.py", line 174, in main
    prospector.print_messages()
  File "/home/jbaiter/.envs/nerkenner-f5Z1Q35w/lib/python3.7/site-packages/prospector/run.py", line 132, in print_messages
    formatter = FORMATTERS[output_format](self.summary, self.messages, self.config.profile)
KeyError: None
> /home/jbaiter/.envs/nerkenner-f5Z1Q35w/lib/python3.7/site-packages/prospector/run.py(132)print_messages()
-> formatter = FORMATTERS[output_format](self.summary, self.messages, self.config.profile)
(Pdb) pp locals()
{'output_files': [],
 'output_format': None,
 'output_reports': [(None, [])],
 'report': (None, []),
 'self': <prospector.run.Prospector object at 0x7f85ab6a70f0>}
(Pdb) self.summary
{'started': datetime.datetime(2018, 7, 30, 14, 56, 49, 706354), 'libraries': [], 'strictness': None, 'profiles': 'default, no_doc_warnings, no_test_warnings, strictness_medium, strictness_high, strictness_veryhigh, no_member_warnings', 'tools': ['dodgy', 'mccabe', 'pep8', 'profile-validator', 'pyflakes', 'pylint'], 'message_count': 1, 'completed': datetime.datetime(2018, 7, 30, 14, 56, 50, 623394), 'time_taken': '0.92', 'formatter': None}
(Pdb) self.messages
[pylint-failure]
(Pdb) pp self.config.__dict__
{'arguments': {'checkpath': []},
 'config': <Configuration(loquacious_pylint=False, strictness=None, without_tools=[], absolute_paths=False, messages_only=False, path=None, full_pep8=None, test_warnings=None, ignore_paths=[], doc_warnings=None, no_style_warnings=None, profiles=[], ignore_patterns=[], summary_only=False, member_warnings=None, autodetect=True, direct_tool_stdout=False, common_plugin=True, uses=[], no_external_config=False, max_line_length=None, profile_path=['/home/jbaiter/projekte/nerkenner', '/home/jbaiter/.envs/nerkenner-f5Z1Q35w/lib/python3.7/site-packages/prospector/profiles/profiles'], pylint_config_file=None, blending=True, show_profile=False, include_tool_stdout=False, tools=None, output_format=None, with_tools=[], zero_exit=False, die_on_tool_error=False)>,
 'configured_by': {'dodgy': None,
                   'mccabe': None,
                   'pep8': None,
                   'profile-validator': None,
                   'pyflakes': None,
                   'pylint': None},
 'explicit_file_mode': False,
 'ignores': [re.compile('^docs?/'),
             re.compile('^tests?/?'),
             re.compile('/tests?(/|$)'),
             re.compile('(^|/)test_[_a-zA-Z0-9]+.py$'),
             re.compile('(^|/)[_a-zA-Z0-9]+_tests?.py$'),
             re.compile('(^|/)tests?.py'),
             re.compile('^setup.py$'),
             re.compile('(^|/)\\..+')],
 'libraries': [],
 'messages': [],
 'paths': ['/home/jbaiter/projekte/nerkenner'],
 'profile': <prospector.profiles.profile.ProspectorProfile object at 0x7f85a98cdc18>,
 'strictness': None,
 'tools_to_run': ['dodgy',
                  'mccabe',
                  'pep8',
                  'profile-validator',
                  'pyflakes',
                  'pylint'],
 'workdir': '/home/jbaiter/projekte/nerkenner'}

@jabdoa2
Copy link

jabdoa2 commented Jul 30, 2018

We also got this error on travis: https://travis-ci.org/missionpinball/mpf/jobs/410025482

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants