12
12
13
13
14
14
MESSAGES = {
15
- 'E%d01' % BASE_ID : ("__unicode__ on a model must be callable (%s)" ,
16
- 'model-unicode-not-callable' ,
17
- "Django models require a callable __unicode__ method" ),
18
- 'W%d01' % BASE_ID : ("No __unicode__ method on model (%s)" ,
19
- 'model-missing-unicode' ,
20
- "Django models should implement a __unicode__ method for string representation" ),
21
- 'W%d02' % BASE_ID : ("Found __unicode__ method on model (%s). Python3 uses __str__." ,
22
- 'model-has-unicode' ,
23
- "Django models should not implement a __unicode__ "
24
- "method for string representation when using Python3" ),
25
- 'W%d03' % BASE_ID : ("Model does not explicitly define __unicode__ (%s)" ,
26
- 'model-no-explicit-unicode' ,
27
- "Django models should implement a __unicode__ method for string representation. "
28
- "A parent class of this model does, but ideally all models should be explicit." )
15
+ f'E { BASE_ID } 01' : ("__unicode__ on a model must be callable (%s)" ,
16
+ 'model-unicode-not-callable' ,
17
+ "Django models require a callable __unicode__ method" ),
18
+ f'W { BASE_ID } 01' : ("No __unicode__ method on model (%s)" ,
19
+ 'model-missing-unicode' ,
20
+ "Django models should implement a __unicode__ method for string representation" ),
21
+ f'W { BASE_ID } 02' : ("Found __unicode__ method on model (%s). Python3 uses __str__." ,
22
+ 'model-has-unicode' ,
23
+ "Django models should not implement a __unicode__ "
24
+ "method for string representation when using Python3" ),
25
+ f'W { BASE_ID } 03' : ("Model does not explicitly define __unicode__ (%s)" ,
26
+ 'model-no-explicit-unicode' ,
27
+ "Django models should implement a __unicode__ method for string representation. "
28
+ "A parent class of this model does, but ideally all models should be explicit." )
29
29
}
30
30
31
31
@@ -102,12 +102,12 @@ def visit_classdef(self, node):
102
102
if assigned .callable ():
103
103
return
104
104
105
- self .add_message ('E%s01' % BASE_ID , args = node .name , node = node )
105
+ self .add_message (f'E { BASE_ID } 01' , args = node .name , node = node )
106
106
return
107
107
108
108
if isinstance (child , FunctionDef ) and child .name == '__unicode__' :
109
109
if PY3 :
110
- self .add_message ('W%s02' % BASE_ID , args = node .name , node = node )
110
+ self .add_message (f'W { BASE_ID } 02' , args = node .name , node = node )
111
111
return
112
112
113
113
# if we get here, then we have no __unicode__ method directly on the class itself
@@ -117,7 +117,7 @@ def visit_classdef(self, node):
117
117
if method .parent != node and _is_unicode_or_str_in_python_2_compatibility (method ):
118
118
# this happens if a parent declares the unicode method but
119
119
# this node does not
120
- self .add_message ('W%s03' % BASE_ID , args = node .name , node = node )
120
+ self .add_message (f'W { BASE_ID } 03' , args = node .name , node = node )
121
121
return
122
122
123
123
# if the Django compatibility decorator is used then we don't emit a warning
@@ -128,4 +128,4 @@ def visit_classdef(self, node):
128
128
if PY3 :
129
129
return
130
130
131
- self .add_message ('W%s01' % BASE_ID , args = node .name , node = node )
131
+ self .add_message (f'W { BASE_ID } 01' , args = node .name , node = node )
0 commit comments