Skip to content
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 pre-commit config #1507

Merged
merged 3 commits into from Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
@@ -0,0 +1,14 @@
repos:
# import sorting with isort
- repo: https://github.com/pycqa/isort
rev: 5.8.0
hooks:
- id: isort

# linting and code analysis with flake8
- repo: https://github.com/pycqa/flake8
rev: 3.8.3
hooks:
- id: flake8
args: ['--config=setup.cfg']
files: cvxpy/
11 changes: 9 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -72,16 +72,23 @@ limitations under the License.
```

## Code style
We use [flake8](http://flake8.pycqa.org/en/latest/) to enforce our Python coding
We use [flake8](https://flake8.pycqa.org/en/latest/) and [isort](https://pycqa.github.io/isort/) to enforce our Python coding
style. Before sending us a pull request, navigate to the project root
and run

```
flake8 cvxpy/
isort .
```

to make sure that your changes abide by our style conventions. Please fix any
errors that flake8 reports before sending the pull request.
errors that are reported before sending the pull request.

Optionally, the package [pre-commit](https://pre-commit.com/) can be installed to check these conventions automatically before every commit.
```
pip install pre-commit
pre-commit install
```

## Writing unit tests
Most code changes will require new unit tests. (Even bug fixes require unit tests,
Expand Down