Skip to content

Enhance CI (add black as pre-commit hook and add pylint checks) #606

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/code-quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ jobs:
#----------------------------------------------
- name: Black
run: poetry run black --check src
#----------------------------------------------
# pylint the code
#----------------------------------------------
- name: Pylint
run: poetry run pylint --rcfile=pylintrc src

check-types:
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
exclude: '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|thrift_api)/'
25 changes: 23 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ The `PySQLStagingIngestionTestSuite` namespace requires a cluster running DBR ve
The suites marked `[not documented]` require additional configuration which will be documented at a later time.


### Code formatting
### Code formatting and linting

This project uses [Black](https://pypi.org/project/black/).
This project uses [Black](https://pypi.org/project/black/) for code formatting and [Pylint](https://pylint.org/) for linting.

#### Black

```
poetry run python3 -m black src --check
Expand All @@ -157,6 +159,25 @@ Remove the `--check` flag to write reformatted files to disk.

To simplify reviews you can format your changes in a separate commit.

#### Pylint

```
poetry run pylint --rcfile=pylintrc src
```

#### Pre-commit hooks

We use [pre-commit](https://pre-commit.com/) to automatically run Black and other checks before each commit.

To set up pre-commit hooks:

```bash
# Set up the git hooks
poetry run pre-commit install
```

This will set up the hooks defined in `.pre-commit-config.yaml` to run automatically on each commit.

### Change a pinned dependency version

Modify the dependency specification (syntax can be found [here](https://python-poetry.org/docs/dependency-specification/)) in `pyproject.toml` and run one of the following in your terminal:
Expand Down
Loading
Loading