Skip to content

Commit

Permalink
Add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorricks committed Mar 8, 2022
1 parent daf037a commit 7431372
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
# Default ignores that we can extend
ignore=D100
max-line-length=120
26 changes: 0 additions & 26 deletions .github/workflows/lint.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint code
on:
push:
pull_request:

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/action@v2.0.3
58 changes: 58 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
minimum_pre_commit_version: "2.9.2"
repos:
- repo: meta
hooks:
- id: identity
- id: check-hooks-apply
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "" # Can not be removed, so leave this empty.
hooks:
- id: prettier
- repo: local
hooks:
- id: no-relative-imports
name: No relative imports.
description: Use absolute imports only.
entry: "^\\s*from\\s+\\."
language: pygrep
- id: isort
name: iSort - Sorts imports.
description: Sorts your import for you.
entry: isort
args: ["--settings-path=pyproject.toml"]
language: python
types: [python]
require_serial: true
additional_dependencies:
- isort
- id: black
name: Black - Auto-formatter.
description: Black is the uncompromising Python code formatter. Writing to files.
entry: black
args: ["--config=pyproject.toml"]
language: python
types: [python]
require_serial: true
additional_dependencies:
- black
- id: flake8
name: Flake8 - Enforce code style and doc.
description: A command-line utility for enforcing style consistency across Python projects.
entry: flake8
args: ["--config=.flake8"]
language: python
types: [python]
require_serial: true
additional_dependencies:
- flake8
- flake8-docstrings
- id: mypy
name: mypy - Static type checking
description: Mypy helps ensure that we use our functions and variables correctly by checking the types.
entry: mypy
args: ["--ignore-missing-imports", "--scripts-are-modules"]
language: python
types: [python]
require_serial: true
additional_dependencies:
- mypy
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ Contributions and suggestions for new features are welcome, as are bug reports!
Please create a new [issue](https://github.com/ewels/rich-click/issues)
or better still, dive right in with a pull-request.

### Local setup
1. Create a new venv with a python3.6+ interpreter using `python3 -m venv venv`
2. Activate the venv with `source venv/bin/activate`
3. Install our the package as an editable including all dev dependencies with `pip3 install -e ."[dev]"`
4. Install pre-commit with `pre-commit install`

## Credits

This package was written by Phil Ewels ([@ewels](http://github.com/ewels/)),
Expand Down
16 changes: 16 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[tool.black]
line-length=120
target-version=['py36']

[tool.isort]
line_length = 120
multi_line_output = 3
force_alphabetical_sort_within_sections = "True"
force_sort_within_sections = "False"
known_richclick = ["rich_click"]
sections=["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER", "RICHCLICK"]
profile = "black"

[tool.mypy]
python_version = "3.6"
ignore_missing_imports = "True"
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@
"rich>=10",
"importlib-metadata; python_version < '3.8'",
],
extras_require={
"dev": ["pre-commit"],
},
)

0 comments on commit 7431372

Please sign in to comment.