diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..ae28ee95 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +ignore = E127,E201,E202,E203,E231,E252,E266,E402,E999,F841,W503,W605 +max-line-length = 80 +exclude = .git,docs,docsrc,scripts,cmdstanpy_tutorial.py,rtd_change_default_version.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a24ee864 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +exclude: 'docsrc' +fail_fast: true +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: check-yaml + # isort should run before black as black sometimes tweaks the isort output + - repo: https://github.com/PyCQA/isort + rev: 5.9.1 + hooks: + - id: isort + # https://github.com/python/black#version-control-integration + - repo: https://github.com/psf/black + rev: 21.6b0 + hooks: + - id: black + - repo: https://github.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + # local uses the user-installed pylint, this allows dependency checking + - repo: local + hooks: + - id: pylint + name: pylint + entry: pylint + language: system + types: [python] + args: [--rcfile=.pylintrc] diff --git a/.pylintrc b/.pylintrc index 43c4f275..2ae00d9e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -7,7 +7,7 @@ extension-pkg-whitelist=ujson # Add files or directories to the blacklist. They should be base names, not # paths. -ignore=CVS +ignore=docsrc/ # Add files or directories matching the regex patterns to the blacklist. The # regex matches against base names, not paths. diff --git a/test/test_generate_quantities.py b/test/test_generate_quantities.py index f77806bb..18ed21fe 100644 --- a/test/test_generate_quantities.py +++ b/test/test_generate_quantities.py @@ -2,6 +2,7 @@ import os import unittest + from pandas.testing import assert_frame_equal from cmdstanpy.cmdstan_args import Method diff --git a/test/test_metadata.py b/test/test_metadata.py index 73d386ca..a364d674 100644 --- a/test/test_metadata.py +++ b/test/test_metadata.py @@ -4,10 +4,9 @@ import unittest from cmdstanpy.cmdstan_args import CmdStanArgs, SamplerArgs -from cmdstanpy.stanfit import RunSet, InferenceMetadata +from cmdstanpy.stanfit import InferenceMetadata, RunSet from cmdstanpy.utils import EXTENSION, check_sampler_csv - HERE = os.path.dirname(os.path.abspath(__file__)) DATAFILES_PATH = os.path.join(HERE, 'data') diff --git a/test/test_sample.py b/test/test_sample.py index eb393869..28b200fa 100644 --- a/test/test_sample.py +++ b/test/test_sample.py @@ -11,7 +11,6 @@ from time import time import numpy as np - import pytest from testfixtures import LogCapture