File tree Expand file tree Collapse file tree 7 files changed +51
-7
lines changed Expand file tree Collapse file tree 7 files changed +51
-7
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "editor.formatOnSave" : true ,
3+ "editor.codeActionsOnSave" : {
4+ "source.fixAll" : " explicit"
5+ },
6+ "editor.rulers" : [
7+ 100
8+ ],
9+ "[python]" : {
10+ "editor.defaultFormatter" : " ms-python.black-formatter"
11+ }
12+ }
Original file line number Diff line number Diff line change 202202 ``` sh
203203 mypy .
204204 ```
205+
206+ 10 . Setup black
207+
208+ - Install black package
209+
210+ ``` sh
211+ pip install black
212+ ```
213+
214+ - Add installed black package to requirements file
215+
216+ ``` sh
217+ pip freeze | grep black >> requirements.txt
218+ ```
219+
220+ - Add black config in ` puproject.toml ` file
221+
222+ ``` toml
223+ [tool .black ]
224+ force-exclude = " /migrations/"
225+ ```
226+
227+ - Fix formatting using black
228+
229+ ``` sh
230+ black .
231+ ```
Original file line number Diff line number Diff line change 3737 "django.contrib.sessions" ,
3838 "django.contrib.messages" ,
3939 "django.contrib.staticfiles" ,
40- ' rest_framework' ,
41- ' core' ,
40+ " rest_framework" ,
41+ " core" ,
4242]
4343
4444MIDDLEWARE = [
Original file line number Diff line number Diff line change 22
33# Create your models here.
44
5+
56class Student (models .Model ):
67 """Student Model"""
78
@@ -10,5 +11,5 @@ class Student(models.Model):
1011
1112 def __str__ (self ):
1213 """Student string representation"""
13-
14- return f"{ self .first_name } { self .last_name } "
14+
15+ return f"{ self .first_name } { self .last_name } "
Original file line number Diff line number Diff line change 44
55# Create your tests here.
66
7+
78class StudentModelTest (TestCase ):
89 def setUp (self ):
910 self .student = Student .objects .create (
@@ -16,8 +17,8 @@ def test_student_creation(self):
1617
1718 self .assertEqual (self .student .first_name , "John" )
1819 self .assertEqual (self .student .last_name , "Doe" )
19-
20+
2021 def test_str_method (self ):
2122 """Test the __str__ method of the Student model."""
22-
23- self .assertEqual (str (self .student ), "John Doe" )
23+
24+ self .assertEqual (str (self .student ), "John Doe" )
Original file line number Diff line number Diff line change 1+ [tool .black ]
2+ force-exclude = " /migrations/"
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ coverage==7.9.2
44mypy == 1.17.0
55django-stubs == 5.2.2
66djangorestframework-stubs == 3.16.1
7+ black == 25.1.0
You can’t perform that action at this time.
0 commit comments