Skip to content

Commit

Permalink
Fix disabled warning not ignored (#4268)
Browse files Browse the repository at this point in the history
* Fix ignores all disabled warnings #4265

* Update changelog and prepare 2.7.4
  • Loading branch information
Pierre-Sassoulas committed Mar 30, 2021
1 parent c1c41b8 commit c92e3ab
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
7 changes: 6 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@ Release date: Undefined

What's New in Pylint 2.7.4?
===========================
Release date: Undefined
Release date: 2021-03-30

..
Put bug fixes that will be cherry-picked to latest major version here


* Fix a problem with disabled msgid not being ignored

Closes #4265

* Fix issue with annotated class constants

* Closes #4264
Expand Down
4 changes: 2 additions & 2 deletions pylint/__pkginfo__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
from os.path import join

# For an official release, use dev_version = None
numversion = (2, 8, 0)
dev_version = 1
numversion = (2, 7, 4)
dev_version = None

version = ".".join(str(num) for num in numversion)
if dev_version is not None:
Expand Down
12 changes: 8 additions & 4 deletions pylint/message/message_handler_mix_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ def get_by_id_managed_msgs(cls):
def _register_by_id_managed_msg(self, msgid_or_symbol: str, line, is_disabled=True):
"""If the msgid is a numeric one, then register it to inform the user
it could furnish instead a symbolic msgid."""
if msgid_or_symbol[1:].isdigit():
symbol = self.msgs_store.message_id_store.get_symbol(msgid=msgid_or_symbol) # type: ignore
managed = (self.current_name, msgid_or_symbol, symbol, line, is_disabled) # type: ignore
MessagesHandlerMixIn.__by_id_managed_msgs.append(managed)
try:
if msgid_or_symbol[1:].isdigit():
symbol = self.msgs_store.message_id_store.get_symbol(msgid=msgid_or_symbol) # type: ignore
msgid = msgid_or_symbol
managed = (self.current_name, msgid, symbol, line, is_disabled) # type: ignore
MessagesHandlerMixIn.__by_id_managed_msgs.append(managed)
except KeyError:
pass

def disable(self, msgid, scope="package", line=None, ignore_unknown=False):
"""Don't output message of the given id"""
Expand Down
6 changes: 6 additions & 0 deletions tests/functional/d/disabled_msgid_in_pylintrc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""https://github.com/PyCQA/pylint/issues/4265"""

try:
f = open('test')
except Exception:
pass
4 changes: 4 additions & 0 deletions tests/functional/d/disabled_msgid_in_pylintrc.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[MESSAGES CONTROL]

disable=
C0111,C0326,W0703

0 comments on commit c92e3ab

Please sign in to comment.