diff --git a/.style.yapf b/.style.yapf index ab82e5ad..66c974c4 100644 --- a/.style.yapf +++ b/.style.yapf @@ -1,4 +1,15 @@ [style] based_on_style = google -split_before_logical_operator = true spaces_before_comment=2, 4 +SPLIT_ARGUMENTS_WHEN_COMMA_TERMINATED = true +SPLIT_ALL_COMMA_SEPARATED_VALUES = true +SPLIT_BEFORE_BITWISE_OPERATOR = true +SPLIT_BEFORE_CLOSING_BRACKET = true +SPLIT_BEFORE_DICT_SET_GENERATOR = true +SPLIT_BEFORE_DOT = true +SPLIT_BEFORE_EXPRESSION_AFTER_OPENING_PAREN = true +SPLIT_BEFORE_FIRST_ARGUMENT = true +SPLIT_BEFORE_LOGICAL_OPERATOR = true +SPLIT_BEFORE_NAMED_ASSIGNS = true +SPLIT_COMPLEX_COMPREHENSION = true +DEDENT_CLOSING_BRACKETS=true diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..fa0ffea0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,12 @@ +language: python +python: + - "3.7-dev" +install: + - pip install -r requirements.txt + - pip install -r travis/requirements.txt + - pip install -r requirements-dev.txt +# command to run tests +script: + - python travis/format_check.py + - pylint --rcfile=.pylintrc vnpy + - python tests/test_all.py diff --git a/Readme.md b/Readme.md new file mode 100644 index 00000000..2b8dd00e --- /dev/null +++ b/Readme.md @@ -0,0 +1,21 @@ +vnpy 2.0 + +## 贡献代码 +--- + +如果你遇到了任何BUG,欢迎[创建 Issue]。 + +我们热烈欢迎任何人为我们的项目贡献代码。无论是多么细小的改工,都可以[提交PR],我们会认真对待每一个PR。 + +在提交代码的时候,请遵守以下规则,以提高代码质量: + + * 使用[yapf](目前必须使用github上的最新代码:```pip install https://github.com/google/yapf/archive/master.zip```)格式化你的代码。对你的每一个文件运行```yapf --style .style.yapf ```即可。 + * 使用[pylint]检查你的代码,确保没有error和warning。我们使用的pylint规则在项目根目录下。运行```pylint --rcfile=pylintrc vnpy```即可。 + + [yapf]:https://github.com/google/yapf + [pylint]:https://github.com/PyCQA/pylint + [提交PR]:https://help.github.com/articles/creating-a-pull-request/ + [创建 Issue]:http://pylint.pycqa.org/en/latest/tutorial.html + + + diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..6325b67f --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +pylint +https://github.com/google/yapf/archive/master.zip diff --git a/tests/test_all.py b/tests/test_all.py new file mode 100644 index 00000000..f636d3fd --- /dev/null +++ b/tests/test_all.py @@ -0,0 +1,4 @@ +import unittest + +if __name__ == '__main__': + unittest.main() diff --git a/travis/format_check.py b/travis/format_check.py new file mode 100644 index 00000000..c1455f19 --- /dev/null +++ b/travis/format_check.py @@ -0,0 +1,27 @@ +import logging +import os + +from yapf.yapflib.yapf_api import FormatFile + +logger = logging.Logger(__file__) + +if __name__ == '__main__': + has_changed = False + for root, dir, filenames in os.walk("vnpy"): + for filename in filenames: + basename, ext = os.path.splitext(filename) + if ext == '.py': + path = os.path.join(root, filename) + reformatted_code, encoding, changed = FormatFile(filename=path, + style_config='.style.yapf', + print_diff=True, + verify=False, + in_place=False, + logger=None + ) + if changed: + has_changed = True + logger.warning("File {} not formatted!".format(path)) + else: + logger.info("File {} is formatted!".format(path)) + exit(has_changed) diff --git a/travis/requirements.txt b/travis/requirements.txt new file mode 100644 index 00000000..e69de29b