Skip to content

Commit

Permalink
Merge pull request #6 from infocusp/hetul/add-ruff
Browse files Browse the repository at this point in the history
Add ruff for automatic linting and formatting
  • Loading branch information
hetulvp authored Apr 15, 2024
2 parents 54d741d + 780409c commit 99baa0e
Show file tree
Hide file tree
Showing 10 changed files with 397 additions and 201 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Linting
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff
# Update output format to enable automatic inline annotations.
- name: Run Ruff
run: ruff check --output-format=github .
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
site/*
.vscode/*
site/*
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"charliermarsh.ruff"
]
}
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"editor.rulers": [
80
]
}
4 changes: 4 additions & 0 deletions contribute/CONTRIBUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Seminar Series. Make sure to read it before opening a PR.
* Maintaining a consistent style across all the articles provides a good reading experience to our readers and often reduces review time.
* We have provided code and text style guides [separately here](STYLE_GUIDES.md).
* You can refer them when crafting that perfect article.
* Please use the following commands,
* Install ruff: `pip install -r requirements.txt`
* Run auto formatter: `ruff format`
* Run linter and fix remaining issues manually `ruff check`

### Step 7: Run the website locally

Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.ruff]
lint.select = [
"D", # pydocstyle
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"T201", # print
"E501" # line-too-long
]
# Set the maximum line length to 79.
line-length = 79

# TODO(hetul): Fix the formatting and do not exclude this dir.
exclude = ["./session_4/part_2_finetuning_lms_to_human_preferences/mingpt/*"]

# Ignore import violations in all `__init__.py` files and missing docstring.
[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["E402", "F401", "F403", "F811", "D104"]

[tool.ruff.lint.pydocstyle]
convention = "google"
Loading

0 comments on commit 99baa0e

Please sign in to comment.