Skip to content

Commit 693bde5

Browse files
set up pylint with sane defaults, black as pre-commit hook
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent c123af3 commit 693bde5

File tree

6 files changed

+356
-13
lines changed

6 files changed

+356
-13
lines changed

.github/workflows/code-quality-checks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ jobs:
156156
#----------------------------------------------
157157
- name: Black
158158
run: poetry run black --check src
159+
#----------------------------------------------
160+
# pylint the code
161+
#----------------------------------------------
162+
- name: Pylint
163+
run: poetry run pylint --rcfile=pylintrc src
159164

160165
check-types:
161166
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-added-large-files
8+
9+
- repo: https://github.com/psf/black
10+
rev: 22.3.0
11+
hooks:
12+
- id: black
13+
exclude: '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist|thrift_api)/'

CONTRIBUTING.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ The `PySQLStagingIngestionTestSuite` namespace requires a cluster running DBR ve
145145
The suites marked `[not documented]` require additional configuration which will be documented at a later time.
146146

147147

148-
### Code formatting
148+
### Code formatting and linting
149149

150-
This project uses [Black](https://pypi.org/project/black/).
150+
This project uses [Black](https://pypi.org/project/black/) for code formatting and [Pylint](https://pylint.org/) for linting.
151+
152+
#### Black
151153

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

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

162+
#### Pylint
163+
164+
```
165+
poetry run pylint --rcfile=pylintrc src
166+
```
167+
168+
#### Pre-commit hooks
169+
170+
We use [pre-commit](https://pre-commit.com/) to automatically run Black and other checks before each commit.
171+
172+
To set up pre-commit hooks:
173+
174+
```bash
175+
# Set up the git hooks
176+
poetry run pre-commit install
177+
```
178+
179+
This will set up the hooks defined in `.pre-commit-config.yaml` to run automatically on each commit.
180+
160181
### Change a pinned dependency version
161182

162183
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:

0 commit comments

Comments
 (0)