Skip to content

Commit

Permalink
ruff (#77)
Browse files Browse the repository at this point in the history
* update sqlfluff

* add ruff linter

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix
  • Loading branch information
sgmdlt authored Nov 12, 2024
1 parent 0b7bf57 commit 4fa756c
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
- 'eslint/**'
nulllint:
- 'nulllint/**'
python-ruff:
- 'python-ruff/**'
- id: set_directories
run: echo "directories=${{ toJson(steps.changes.outputs.changes) }}" >> "$GITHUB_OUTPUT"
Expand Down
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build: build-php build-js build-java build-null build-sql build-python-flake8 build-layout-designer-lint build-multi-language build-go
build: build-php build-js build-java build-null build-sql build-python-flake8 build-layout-designer-lint build-multi-language build-go build-python-ruff

build-multi-language:
docker build -t hexlet/common-multi-language multi-language
Expand All @@ -21,6 +21,9 @@ build-null:
build-python-flake8:
docker build -t hexlet/common-python-flake8 python-flake8

build-python-ruff:
docker build -t hexlet/common-python-ruff python-ruff

build-layout-designer-lint:
docker build -t hexlet/common-layout-designer-lint layout-designer-lint

Expand Down Expand Up @@ -62,6 +65,14 @@ lint-python-flake8:
-v $(CURDIR)/python-flake8/setup.cfg:/linter/setup.cfg \
hexlet/common-python-flake8

lint-python-ruff:
docker run --rm -t --read-only -v $(CURDIR)/python-ruff/app:/usr/src/app \
-v $(CURDIR)/python-ruff/linter:/linter/linter \
-v $(CURDIR)/python-ruff/ruff.toml:/linter/ruff.toml \
-v /var/tmp/.ruff_cache \
hexlet/common-python-ruff


lint-layout-designer:
docker run --rm -t --read-only -v $(CURDIR)/layout-designer-lint/app:/usr/src/app \
-v $(CURDIR)/layout-designer-lint/package.json:/linter/package.json \
Expand Down
13 changes: 13 additions & 0 deletions python-ruff/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.13-alpine

RUN apk add --no-cache bash

WORKDIR /linter

RUN pip install --target ./lib ruff
ENV PATH=$PATH:/linter/lib/bin

COPY linter .
COPY ruff.toml .

CMD ["./linter"]
1 change: 1 addition & 0 deletions python-ruff/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from bad1 import NUMBERS
1 change: 1 addition & 0 deletions python-ruff/app/bad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
func ( [1,2,3]) #this line lots PEP8 errors :)
6 changes: 6 additions & 0 deletions python-ruff/app/bad1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
NUMBERS = [
1,
2
]

text = 'some long text some long text some long text some long text some long text some long text'
3 changes: 3 additions & 0 deletions python-ruff/app/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extend = "/linter/ruff.toml"

line-length = 100
14 changes: 14 additions & 0 deletions python-ruff/linter
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

LINTER_HOME=$(dirname $0)

RULESET=/usr/src/app/ruff.toml

if [ -f $RULESET ]
then
CONFIG=$RULESET
else
CONFIG=$LINTER_HOME/ruff.toml
fi

$LINTER_HOME/lib/bin/ruff check /usr/src/app --config=$CONFIG
14 changes: 14 additions & 0 deletions python-ruff/ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
line-length = 80
cache-dir = "/var/tmp/.ruff_cache"

[lint.per-file-ignores]
# init modules can contain the local imports, logic, unused imports
"__init__.py" = ["F401"]
"test_*.py" = ["E501"]

[lint]
preview = true
select = ["E", "F", "C90", "W"]

[lint.mccabe]
max-complexity = 6

0 comments on commit 4fa756c

Please sign in to comment.