-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit config + linting + update README
- Loading branch information
1 parent
089c432
commit 4570433
Showing
7 changed files
with
90 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
exclude: "docs|migrations|.git" | ||
default_stages: [commit] | ||
fail_fast: true | ||
|
||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.3.0 | ||
hooks: | ||
- id: black | ||
exclude: ^.*\b(migrations)\b.*$ | ||
args: ["--target-version", "py310"] | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.1.0 | ||
hooks: | ||
- id: pyupgrade | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-merge-conflict | ||
- id: debug-statements | ||
- id: mixed-line-ending | ||
- id: requirements-txt-fixer | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.10.1 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/PyCQA/flake8 | ||
rev: 4.0.1 | ||
hooks: | ||
- id: flake8 | ||
args: ["--ignore=E501,W503,F403,F405,E203"] | ||
additional_dependencies: [flake8-isort] | ||
|
||
- repo: https://github.com/asottile/pyupgrade | ||
rev: v3.3.1 | ||
hooks: | ||
- id: pyupgrade | ||
|
||
# sets up .pre-commit-ci.yaml to ensure pre-commit dependencies stay up to date | ||
ci: | ||
autoupdate_schedule: weekly | ||
skip: [] | ||
submodules: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
## Django Playground | ||
|
||
- Test sandbox to practice and experiment with Django ORM queries | ||
- Test sandbox to practice and experiment with Django ORM queries, third party packages, and miscellaneous items | ||
|
||
### Setup (OSX/Linux) | ||
|
||
1. `chmod +x setup.sh` | ||
1. `./setup.sh` | ||
|
||
### Testing | ||
|
||
1. `pytest` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,7 @@ def test_does_not_make_unnecessary_queries(client, django_assert_max_num_queries | |
|
||
|
||
class TestPerfViews: | ||
def test_does_not_make_unnecessary_queries( | ||
self, client, django_assert_max_num_queries | ||
): | ||
def test_does_not_make_unnecessary_queries(self, client, django_assert_max_num_queries): | ||
with django_assert_max_num_queries(2): | ||
client.get(reverse("users-list")) | ||
|
||
|
@@ -77,9 +75,7 @@ def test_post_request_users_view(self, api_client): | |
class TestCasePytest(TestCase): | ||
def setUp(self): | ||
self.instance = 3 | ||
User.objects.create( | ||
username="test", email="[email protected]", password="password" | ||
) | ||
User.objects.create(username="test", email="[email protected]", password="password") | ||
|
||
def test_setup_works(self): | ||
assert self.instance == 3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[tool.black] | ||
line-length = 150 | ||
exclude = ''' | ||
/( | ||
| migrations | ||
| venv | ||
)/ | ||
''' | ||
|
||
[tool.isort] | ||
profile = "black" | ||
atomic = true | ||
|
||
[tool.pytest.ini_options] | ||
DJANGO_SETTINGS_MODULE = "django_playground.settings" | ||
minversion = "6.0" | ||
addopts = "--reuse-db" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
asgiref==3.4.1 | ||
attrs==22.1.0 | ||
black==21.8b0 | ||
cfgv==3.3.1 | ||
click==8.0.1 | ||
distlib==0.3.6 | ||
Django==3.2.7 | ||
django-debug-toolbar==3.2.2 | ||
django-extensions==3.1.5 | ||
djangorestframework==3.13.1 | ||
Faker==8.12.1 | ||
filelock==3.9.0 | ||
graphviz==0.20 | ||
identify==2.5.16 | ||
iniconfig==1.1.1 | ||
isort==5.9.3 | ||
mypy-extensions==0.4.3 | ||
nodeenv==1.7.0 | ||
packaging==21.3 | ||
pathspec==0.9.0 | ||
platformdirs==2.3.0 | ||
platformdirs==2.6.2 | ||
pluggy==1.0.0 | ||
pre-commit==3.0.2 | ||
py==1.11.0 | ||
pyparsing==3.0.9 | ||
pytest==7.1.3 | ||
pytest-django==4.5.2 | ||
python-dateutil==2.8.2 | ||
pytz==2021.1 | ||
PyYAML==6.0 | ||
regex==2021.8.28 | ||
six==1.16.0 | ||
sqlparse==0.4.1 | ||
text-unidecode==1.3 | ||
tomli==1.2.1 | ||
typing-extensions==3.10.0.2 | ||
virtualenv==20.17.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ source venv/bin/activate | |
pip install -r requirements.txt | ||
python manage.py migrate | ||
python manage.py createsuperuser --no-input --username admin --email [email protected] | ||
python manage.py seed_data | ||
python manage.py runserver |