Skip to content

Commit

Permalink
Introducing pre-commit hooks
Browse files Browse the repository at this point in the history
In a intention to increase code quality and reducing faulty commits,
pre-commits help checking the staged code for simple static code
analysis.
  • Loading branch information
willianpaixao committed Jan 23, 2020
1 parent 6f72d19 commit 11dadca
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ install:
- 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: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:
# "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
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ TAGS

.gdb_history

*.dSYM/
*.dSYM/
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ install:
# 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.
- 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:
# "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
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
engine powering `Quantopian <https://www.quantopian.com>`_ -- a free,
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.

- `Join our Community! <https://groups.google.com/forum/#!forum/zipline>`_
Expand Down
8 changes: 4 additions & 4 deletions docs/source/development-guidelines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

.. code-block:: bash
$ 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.
Expand Down Expand Up @@ -122,7 +122,7 @@ Then run ``pip install`` TA-lib:
You should now be free to run tests:

.. code-block:: bash
$ nosetests
Expand All @@ -144,7 +144,7 @@ Packaging
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

Contributing to the Docs
------------------------

Expand Down Expand Up @@ -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
divide by zero error.
Instead of papering over that error, the entire calculation was
a bit suspect so removing, with possibility of adding it back in
later with handling the case (or raising appropriate errors) when
Expand Down
11 changes: 5 additions & 6 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ channel:
Managing ``conda`` environments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is recommended to install Zipline in an isolated ``conda`` environment.
Installing Zipline in ``conda`` environments will not interfere your default
Python deployment or site-packages, which will prevent any possible conflict
with your global libraries. For more information on ``conda`` environment, see
It is recommended to install Zipline in an isolated ``conda`` environment.
Installing Zipline in ``conda`` environments will not interfere your default
Python deployment or site-packages, which will prevent any possible conflict
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>`_

Assuming ``conda`` has been set up, you can create a ``conda`` environment:
Expand All @@ -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
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

.. code-block:: bash
Expand All @@ -164,4 +164,3 @@ To deactivate the ``conda`` environment:
.. code-block:: bash
(env_zipline) $ source deactivate
2 changes: 1 addition & 1 deletion etc/ordered_pip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

a=0
while read line
do
do
if [[ -n "$line" && "$line" != \#* ]] ; then
# forward to pip any args after the reqs filename
pip install --exists-action w $line "${@:2}"
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ versionfile_source=zipline/_version.py
versionfile_build=zipline/_version.py
tag_prefix=
parentdir_prefix= zipline-

[flake8]
exclude =
versioneer.py
1 change: 0 additions & 1 deletion zipline/api.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -811,4 +811,3 @@ def symbols(*args):
--------
:func:`zipline.api.set_symbol_lookup_date`
"""

Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ HOML
GDXX
GDJJ
GDXS
SMHD
SMHD

0 comments on commit 11dadca

Please sign in to comment.