-
Notifications
You must be signed in to change notification settings - Fork 180
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
add python code style lint and format #147
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# http://editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
# We recommend you to keep these unchanged | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.py] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ SMALL ?= 'tests/small' | |
MEDIUM ?= 'tests/medium' | ||
LARGE ?= 'tests/large' | ||
XLARGE ?= 'tests/xlarge' | ||
NEWLY_ADDED_PY_FILES = $(shell git ls-files -o --exclude-standard | grep -E '\.py$$') | ||
CHANGED_ADDED_PY_FILES = $(shell git ls-files -mo --exclude-standard | grep -E '\.py$$') | ||
|
||
.PHONY: tests | ||
.PHONY: tests, lint, format | ||
|
||
all: egg | ||
|
||
|
@@ -101,3 +103,24 @@ docs: | |
|
||
build_spl: clean | ||
python -m splunk_eventgen build --destination ./ | ||
|
||
lint: | ||
ifeq ($(NEWLY_ADDED_PY_FILES), ) | ||
@echo 'No newly added python files. Skip...' | ||
else | ||
@flake8 $(NEWLY_ADDED_PY_FILES) || true | ||
endif | ||
@git diff -U0 -- '*.py' | flake8 --diff || true | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
format: | ||
ifeq ($(CHANGED_ADDED_PY_FILES), ) | ||
@echo 'No changed python files. Skip...' | ||
else | ||
@isort $(CHANGED_ADDED_PY_FILES) | ||
endif | ||
ifeq ($(NEWLY_ADDED_PY_FILES), ) | ||
@echo 'No newly added python files. Skip...' | ||
else | ||
@yapf -i $(NEWLY_ADDED_PY_FILES) | ||
endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
[flake8] | ||
exclude = .git,.tox,__pycache__,env,venv | ||
exclude = .git,.tox,__pycache__,env,venv,build,dist,docs | ||
max-line-length = 120 | ||
|
||
[metadata] | ||
description-file = README.md | ||
version-from-file: __init__.py | ||
|
||
[yapf] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
based_on_style = pep8 | ||
spaces_before_comment = 4 | ||
split_before_logical_operator = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make lint
will only lint the newly added and changed parts of python files here.