Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Release date: TBA
* The ``PyLinter`` class will now be initialiazed with a ``TextReporter``
as its reporter if none is provided.

* Fatal errors now emit a score of 0.0 regardless if the linted module
contained any statements.

Closes #5451

* Fix false positive - Allow unpacking of ``self`` in a subclass of ``typing.NamedTuple``.

Closes #5312
Expand Down
7 changes: 6 additions & 1 deletion doc/whatsnew/2.13.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,10 @@ Other Changes

Closes #5065

* The ``PyLinter`` class will now be initialiazed with a ``TextReporter``
* Fatal errors now emit a score of 0.0 regardless if the linted module
contained any statements.

Closes #5451

* The ``PyLinter`` class will now be initialized with a ``TextReporter``
as its reporter if none is provided.
4 changes: 3 additions & 1 deletion pylint/lint/pylinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ def enable_fail_on_messages(self):
self.enable(msg.msgid)
self.fail_on_symbols.append(msg.symbol)
elif msg.msgid[0] in fail_on_cats:
# message starts with a cateogry value, flag (but do not enable) it
# message starts with a category value, flag (but do not enable) it
self.fail_on_symbols.append(msg.symbol)

def any_fail_on_issues(self):
Expand Down Expand Up @@ -1326,6 +1326,8 @@ def _report_evaluation(self):
except Exception as ex: # pylint: disable=broad-except
msg = f"An exception occurred while rating: {ex}"
else:
if self.stats.by_msg.get("fatal", 0):
note = 0.0
Comment thread
jacobtylerwalls marked this conversation as resolved.
Outdated
self.stats.global_note = note
msg = f"Your code has been rated at {note:.2f}/10"
if previous_stats:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,14 @@ def test_fail_on_exit_code(self, args, expected):
# and errors that are generated they don't affect the exit code.
self._runtest([path, "--fail-under=-10"] + args, code=expected)

def test_one_module_fatal_error(self):
"""
Fatal errors in one of several modules linted still exits non-zero.
"""
valid_path = join(HERE, "conftest.py")
invalid_path = join(HERE, "garbagePath.py")
self._runtest([valid_path, invalid_path], code=1)
Comment thread
DanielNoord marked this conversation as resolved.

@pytest.mark.parametrize(
"args, expected",
[
Expand Down