Skip to content

Commit

Permalink
Added editorconfig, black, flake8, isort, pre-commit (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
jslay-excella committed Apr 18, 2022
1 parent 15e325f commit 1d7bc3d
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
20 changes: 20 additions & 0 deletions .editorconfig
@@ -0,0 +1,20 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

# Matches multiple files with brace expansion notation
# Set default charset
# Set max line length
# 4 space indentation
[*.py]
charset = utf-8
max_line_length = 79
indent_style = space
indent_size = 4
23 changes: 23 additions & 0 deletions .flake8
@@ -0,0 +1,23 @@
[flake8]
max-line-length = 79
select = C,E,F,W,B,B950
ignore =
# black https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length
E203, E501
# There's nothing wrong with assigning lambdas
E731,
# PEP8 weakly recommends Knuth-style line breaks before binary
# operators
W503, W504
exclude =
# These are directories that it's a waste of time to traverse
.git,
.tox,
.venv,
docs,
venv,

# Generated migration files will throw errors. We need to find a way
# to exclude django-generated migrations while including
# manually-written migrations.
*/migrations/*.py,
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -70,3 +70,6 @@ bower_components/
.grunt/
src/vendor/
dist/

# IDEs
.idea/
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,18 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args: ["treemodeladmin", "setup.py", "--line-length=79"]
exclude: migrations
- repo: https://gitlab.com/pycqa/flake8
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear==22.1.11]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ["treemodeladmin"]
17 changes: 17 additions & 0 deletions pyproject.toml
Expand Up @@ -20,5 +20,22 @@ exclude = '''
)
'''

[tool.isort]
profile = "black"
line_length = 79
lines_after_imports = 2
skip = [".tox", "migrations", ".venv", "venv"]
known_django = ["django"]
known_wagtail = ["wagtail"]
default_section = "THIRDPARTY"
sections = [
"STDLIB",
"DJANGO",
"WAGTAIL",
"THIRDPARTY",
"FIRSTPARTY",
"LOCALFOLDER"
]

[build-system]
requires = ["setuptools", "wheel"]
3 changes: 2 additions & 1 deletion treemodeladmin/tests/urls.py
Expand Up @@ -4,7 +4,8 @@
try:
from django.urls import include, re_path
except ImportError:
from django.conf.urls import include, url as re_path
from django.conf.urls import include
from django.conf.urls import url as re_path


urlpatterns = [
Expand Down

0 comments on commit 1d7bc3d

Please sign in to comment.