[pylint] Do not report methods with only one EM101-compatible raise (PLR6301) (#15507)

This commit is contained in:
InSync 2025-01-17 16:17:39 +07:00 committed by GitHub
parent 1ecb7ce645
commit dbfdaaded1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 80 additions and 1 deletions

View file

@ -103,3 +103,40 @@ class Foo:
def validate_y(self, attribute, value):
if value <= 0:
raise ValueError("y must be a positive integer")
class Foo:
# No errors
def string(self):
msg = ""
raise NotImplementedError(msg)
def fstring(self, x):
msg = f"{x}"
raise NotImplementedError(msg)
def docstring(self):
"""Lorem ipsum dolor sit amet."""
msg = ""
raise NotImplementedError(msg)
# Errors
def non_simple_assignment(self):
msg = foo = ""
raise NotImplementedError(msg)
def non_simple_assignment_2(self):
msg[0] = ""
raise NotImplementedError(msg)
def unused_message(self):
msg = ""
raise NotImplementedError("")
def unused_message_2(self, x):
msg = ""
raise NotImplementedError(x)