Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added editorconfig, black, flake8, isort, pre-commit #30

Merged
merged 1 commit into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,6 @@ bower_components/
.grunt/
src/vendor/
dist/

# IDEs
.idea/
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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