Skip to content

Commit 8dd70cb

Browse files
committed
Check also for unicode.format when exempting str.format with self from redundant-keyword-arg. Close #1676
1 parent 5a46ae8 commit 8dd70cb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pylint/checkers/typecheck.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
from pylint.utils import get_global_option
5555

5656
BUILTINS = six.moves.builtins.__name__
57-
STR_FORMAT = "%s.str.format" % BUILTINS
57+
STR_FORMAT = {"%s.str.format" % BUILTINS}
58+
if six.PY2:
59+
STR_FORMAT.add("%s.unicode.format" % BUILTINS)
5860

5961

6062
def _unflatten(iterable):
@@ -941,7 +943,7 @@ def visit_call(self, node):
941943
# by keyword argument, as in `.format(self=self)`.
942944
# It's perfectly valid to so, so we're just skipping
943945
# it if that's the case.
944-
if not (keyword == 'self' and called.qname() == STR_FORMAT):
946+
if not (keyword == 'self' and called.qname() in STR_FORMAT):
945947
self.add_message('redundant-keyword-arg',
946948
node=node, args=(keyword, callable_name))
947949
else:

0 commit comments

Comments
 (0)