1212
1313
1414MESSAGES = {
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." )
2929}
3030
3131
@@ -102,12 +102,12 @@ def visit_classdef(self, node):
102102 if assigned .callable ():
103103 return
104104
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 )
106106 return
107107
108108 if isinstance (child , FunctionDef ) and child .name == '__unicode__' :
109109 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 )
111111 return
112112
113113 # if we get here, then we have no __unicode__ method directly on the class itself
@@ -117,7 +117,7 @@ def visit_classdef(self, node):
117117 if method .parent != node and _is_unicode_or_str_in_python_2_compatibility (method ):
118118 # this happens if a parent declares the unicode method but
119119 # 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 )
121121 return
122122
123123 # if the Django compatibility decorator is used then we don't emit a warning
@@ -128,4 +128,4 @@ def visit_classdef(self, node):
128128 if PY3 :
129129 return
130130
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