Skip to content

Commit 3a0c111

Browse files
authored
Merge pull request #18 from Mng-dev-ai/add-linting
Add linting
2 parents f63c7e1 + ce86361 commit 3a0c111

File tree

21 files changed

+1447
-1486
lines changed

21 files changed

+1447
-1486
lines changed

.DS_Store

8 KB
Binary file not shown.

.github/workflows/test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
python-version: ["3.9", "3.10"]
10+
python-version: ["3.8","3.9"]
1111
os: [ubuntu-latest, macos-latest, windows-latest]
1212

1313
steps:
@@ -25,3 +25,6 @@ jobs:
2525
2626
- name: Run tests
2727
run: python runtests.py
28+
29+
- name: Run linting checks
30+
run: bash scripts/check

CONTRIBUTING.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ Ready to contribute? Here's how to set up `drf-turbo` for local development.
7575

7676
Now you can make your changes locally.
7777

78-
5. The next step would be to run the test cases. Before you run runtests you should ensure all dependencies are installed
78+
5. When you're done making changes, check that your changes pass flake8,black,isort and the tests. you should ensure all dependencies are installed
7979

8080
$ pip install -r requirements_dev.txt
81-
$ python3 runtests.py
81+
$ bash scripts/check
82+
$ pytest
8283

8384
6. Commit your changes and push your branch to GitHub::
8485

docs/.DS_Store

8 KB
Binary file not shown.

docs/conf.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
autoclass_content = "both"
3030

3131
# Theme
32-
html_theme = 'furo'
32+
html_theme = "furo"
3333

3434

3535
html_sidebars = {
@@ -42,6 +42,3 @@
4242
"sidebar/scroll-end.html",
4343
]
4444
}
45-
46-
47-

drf_turbo/__init__.py

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,49 @@
1-
from drf_turbo.serializer import BaseSerializer,Serializer,ModelSerializer
2-
from drf_turbo.fields import (
3-
Field,StrField,EmailField,URLField,RegexField,IPField,PasswordField,UUIDField,SlugField,IntField,FloatField,DecimalField,BoolField,ChoiceField,MultipleChoiceField,DateTimeField,DateField,TimeField,FileField,ArrayField,DictField,JSONField,RelatedField,ManyRelatedField,ConstantField,RecursiveField,MethodField
4-
)
51
from drf_turbo.exceptions import ValidationError
2+
from drf_turbo.fields import (ArrayField, BoolField, ChoiceField,
3+
ConstantField, DateField, DateTimeField,
4+
DecimalField, DictField, EmailField, Field,
5+
FileField, FloatField, IntField, IPField,
6+
JSONField, ManyRelatedField, MethodField,
7+
MultipleChoiceField, PasswordField,
8+
RecursiveField, RegexField, RelatedField,
9+
SlugField, StrField, TimeField, URLField,
10+
UUIDField)
11+
from drf_turbo.serializer import BaseSerializer, ModelSerializer, Serializer
612

713
__author__ = """Michael Gendy"""
8-
__email__ = '[email protected]'
9-
__version__ = '0.1.6'
14+
__email__ = "[email protected]"
15+
__version__ = "0.1.6"
1016

1117
__all__ = [
12-
'BaseSerializer',
13-
'Serializer',
14-
'ModelSerializer',
15-
'Field',
16-
'StrField',
17-
'EmailField',
18-
'URLField',
19-
'RegexField',
20-
'IPField',
21-
'PasswordField',
22-
'UUIDField',
23-
'SlugField',
24-
'IntField',
25-
'FloatField',
26-
'DecimalField',
27-
'BoolField',
28-
'ChoiceField',
29-
'MultipleChoiceField',
30-
'DateTimeField',
31-
'DateField',
32-
'TimeField',
33-
'FileField',
34-
'ArrayField',
35-
'DictField',
36-
'JSONField',
37-
'RelatedField',
38-
'ManyRelatedField',
39-
'ConstantField',
40-
'RecursiveField',
41-
'MethodField',
42-
'ValidationError',
18+
"BaseSerializer",
19+
"Serializer",
20+
"ModelSerializer",
21+
"Field",
22+
"StrField",
23+
"EmailField",
24+
"URLField",
25+
"RegexField",
26+
"IPField",
27+
"PasswordField",
28+
"UUIDField",
29+
"SlugField",
30+
"IntField",
31+
"FloatField",
32+
"DecimalField",
33+
"BoolField",
34+
"ChoiceField",
35+
"MultipleChoiceField",
36+
"DateTimeField",
37+
"DateField",
38+
"TimeField",
39+
"FileField",
40+
"ArrayField",
41+
"DictField",
42+
"JSONField",
43+
"RelatedField",
44+
"ManyRelatedField",
45+
"ConstantField",
46+
"RecursiveField",
47+
"MethodField",
48+
"ValidationError",
4349
]
44-
45-
46-
47-
48-

drf_turbo/exceptions.pyx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22

33
from drf_turbo.utils import get_execption_detail
44

5+
56
cdef class DrfTurboException(Exception):
6-
"""Base class for all fast_rest-related errors."""
7+
"""
8+
Base class for all exceptions raised by drf_turbo.
9+
"""
710
status_code = 500
811
default_detail = 'A server error occurred.'
912
default_code = 'error'
10-
13+
1114
def __cinit__(self, detail=None, code=None) -> None:
1215
if detail is None:
1316
detail = self.default_detail
1417
if code is None:
1518
code = self.default_code
16-
19+
1720
self.detail = get_execption_detail(detail)
18-
21+
1922
def __str__(self) -> str:
2023
return str(self.detail)
2124

@@ -28,15 +31,16 @@ cdef class ValidationError(DrfTurboException):
2831
detail = self.default_detail
2932
if code is None:
3033
code = self.default_code
31-
34+
3235
if isinstance(detail, tuple):
3336
detail = list(detail)
3437
elif not isinstance(detail, dict) and not isinstance(detail, list):
3538
detail = [detail]
3639

3740
self.detail = get_execption_detail(detail)
38-
39-
class StringNotCollectionError(DrfTurboException,TypeError):
41+
42+
43+
class StringNotCollectionError(DrfTurboException, TypeError):
4044
pass
4145

4246

0 commit comments

Comments
 (0)