Introducing pre-commit hooks

In a intention to increase code quality and reducing faulty commits,
pre-commits help checking the staged code for simple static code
analysis.
This commit is contained in:
Willian Paixao 2020-01-23 20:41:14 +01:00
parent 6f72d19554
commit 11dadcaba4
No known key found for this signature in database
GPG key ID: EC28B80C874D7222
11 changed files with 27 additions and 17 deletions

View file

@ -94,7 +94,7 @@ install:
- ps: $env:PYTABLES_VERSION=(sls "tables==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value - ps: $env:PYTABLES_VERSION=(sls "tables==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value
- ps: $env:H5PY_VERSION=(sls "h5py==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value - ps: $env:H5PY_VERSION=(sls "h5py==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value
- ps: $env:TALIB_VERSION=(sls "TA-Lib==(.*)" .\etc\requirements_talib.txt -ca).matches.groups[1].value - ps: $env:TALIB_VERSION=(sls "TA-Lib==(.*)" .\etc\requirements_talib.txt -ca).matches.groups[1].value
# We conda install certifi at the pinned exact version because it is a transitive dependency of zipline via requests and uses distutils for packaging. # We conda install certifi at the pinned exact version because it is a transitive dependency of zipline via requests and uses distutils for packaging.
# Since conda installs latest certifi by default, we would fail to uninstall that new version when trying to install the pinned version using pip later in the build: # Since conda installs latest certifi by default, we would fail to uninstall that new version when trying to install the pinned version using pip later in the build:
# "Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall." # "Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall."
- ps: $env:CERTIFI_VERSION=(sls "certifi==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value - ps: $env:CERTIFI_VERSION=(sls "certifi==(.*)" .\etc\requirements.txt -ca).matches.groups[1].value

2
.gitignore vendored
View file

@ -77,4 +77,4 @@ TAGS
.gdb_history .gdb_history
*.dSYM/ *.dSYM/

8
.pre-commit-config.yaml Normal file
View file

@ -0,0 +1,8 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v2.4.0'
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: flake8

View file

@ -73,7 +73,7 @@ install:
# Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads. # Make sure stdout is in blocking mode. If we don't, then conda create will barf during downloads.
# See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details. # See https://github.com/travis-ci/travis-ci/issues/4704#issuecomment-348435959 for details.
- python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);' - python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
# We conda install certifi at the pinned exact version because it is a transitive dependency of zipline via requests and uses distutils for packaging. # We conda install certifi at the pinned exact version because it is a transitive dependency of zipline via requests and uses distutils for packaging.
# Since conda installs latest certifi by default, we would fail to uninstall that new version when trying to install the pinned version using pip later in the build: # Since conda installs latest certifi by default, we would fail to uninstall that new version when trying to install the pinned version using pip later in the build:
# "Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall." # "Cannot uninstall 'certifi'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall."
- conda create -n testenv --use-local --yes -c quantopian -c quantopian/label/ci pip python=$TRAVIS_PYTHON_VERSION numpy=$NUMPY_VERSION pandas=$PANDAS_VERSION scipy=$SCIPY_VERSION ta-lib=$TALIB_VERSION libgfortran=3.0 certifi=$CERTIFI_VERSION - conda create -n testenv --use-local --yes -c quantopian -c quantopian/label/ci pip python=$TRAVIS_PYTHON_VERSION numpy=$NUMPY_VERSION pandas=$PANDAS_VERSION scipy=$SCIPY_VERSION ta-lib=$TALIB_VERSION libgfortran=3.0 certifi=$CERTIFI_VERSION

View file

@ -16,7 +16,7 @@ Zipline is a Pythonic algorithmic trading library. It is an event-driven
system for backtesting. Zipline is currently used in production as the backtesting and live-trading system for backtesting. Zipline is currently used in production as the backtesting and live-trading
engine powering `Quantopian <https://www.quantopian.com>`_ -- a free, engine powering `Quantopian <https://www.quantopian.com>`_ -- a free,
community-centered, hosted platform for building and executing trading community-centered, hosted platform for building and executing trading
strategies. Quantopian also offers a `fully managed service for professionals <https://factset.quantopian.com>`_ strategies. Quantopian also offers a `fully managed service for professionals <https://factset.quantopian.com>`_
that includes Zipline, Alphalens, Pyfolio, FactSet data, and more. that includes Zipline, Alphalens, Pyfolio, FactSet data, and more.
- `Join our Community! <https://groups.google.com/forum/#!forum/zipline>`_ - `Join our Community! <https://groups.google.com/forum/#!forum/zipline>`_

View file

@ -20,7 +20,7 @@ First, you'll need to clone Zipline by running:
Then check out to a new branch where you can make your changes: Then check out to a new branch where you can make your changes:
.. code-block:: bash .. code-block:: bash
$ git checkout -b some-short-descriptive-name $ git checkout -b some-short-descriptive-name
If you don't already have them, you'll need some C library dependencies. You can follow the `install guide`__ to get the appropriate dependencies. If you don't already have them, you'll need some C library dependencies. You can follow the `install guide`__ to get the appropriate dependencies.
@ -122,7 +122,7 @@ Then run ``pip install`` TA-lib:
You should now be free to run tests: You should now be free to run tests:
.. code-block:: bash .. code-block:: bash
$ nosetests $ nosetests
@ -144,7 +144,7 @@ Packaging
To learn about how we build Zipline conda packages, you can read `this`__ section in our release process notes. To learn about how we build Zipline conda packages, you can read `this`__ section in our release process notes.
__ release-process.html#uploading-conda-packages __ release-process.html#uploading-conda-packages
Contributing to the Docs Contributing to the Docs
------------------------ ------------------------
@ -209,7 +209,7 @@ __ https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project
At least one of those calculations, max_leverage, was causing a At least one of those calculations, max_leverage, was causing a
divide by zero error. divide by zero error.
Instead of papering over that error, the entire calculation was Instead of papering over that error, the entire calculation was
a bit suspect so removing, with possibility of adding it back in a bit suspect so removing, with possibility of adding it back in
later with handling the case (or raising appropriate errors) when later with handling the case (or raising appropriate errors) when

View file

@ -124,10 +124,10 @@ channel:
Managing ``conda`` environments Managing ``conda`` environments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is recommended to install Zipline in an isolated ``conda`` environment. It is recommended to install Zipline in an isolated ``conda`` environment.
Installing Zipline in ``conda`` environments will not interfere your default Installing Zipline in ``conda`` environments will not interfere your default
Python deployment or site-packages, which will prevent any possible conflict Python deployment or site-packages, which will prevent any possible conflict
with your global libraries. For more information on ``conda`` environment, see with your global libraries. For more information on ``conda`` environment, see
the `Conda User Guide <https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html>`_ the `Conda User Guide <https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html>`_
Assuming ``conda`` has been set up, you can create a ``conda`` environment: Assuming ``conda`` has been set up, you can create a ``conda`` environment:
@ -146,7 +146,7 @@ Assuming ``conda`` has been set up, you can create a ``conda`` environment:
Now you have set up an isolated environment called ``env_zipline``, a sandbox-like Now you have set up an isolated environment called ``env_zipline``, a sandbox-like
structure to install Zipline. Then you should activate the conda environment structure to install Zipline. Then you should activate the conda environment
by using the command by using the command
.. code-block:: bash .. code-block:: bash
@ -164,4 +164,3 @@ To deactivate the ``conda`` environment:
.. code-block:: bash .. code-block:: bash
(env_zipline) $ source deactivate (env_zipline) $ source deactivate

View file

@ -2,7 +2,7 @@
a=0 a=0
while read line while read line
do do
if [[ -n "$line" && "$line" != \#* ]] ; then if [[ -n "$line" && "$line" != \#* ]] ; then
# forward to pip any args after the reqs filename # forward to pip any args after the reqs filename
pip install --exists-action w $line "${@:2}" pip install --exists-action w $line "${@:2}"

View file

@ -22,3 +22,7 @@ versionfile_source=zipline/_version.py
versionfile_build=zipline/_version.py versionfile_build=zipline/_version.py
tag_prefix= tag_prefix=
parentdir_prefix= zipline- parentdir_prefix= zipline-
[flake8]
exclude =
versioneer.py

View file

@ -811,4 +811,3 @@ def symbols(*args):
-------- --------
:func:`zipline.api.set_symbol_lookup_date` :func:`zipline.api.set_symbol_lookup_date`
""" """

View file

@ -32,4 +32,4 @@ HOML
GDXX GDXX
GDJJ GDJJ
GDXS GDXS
SMHD SMHD