Skip to content

Commit bb12bba

Browse files
committed
ci: build doc with uv and use ruff for lint checks instead of flake8
1 parent 1795a8d commit bb12bba

File tree

5 files changed

+29
-21
lines changed

5 files changed

+29
-21
lines changed

.github/workflows/static-gh-pages.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ jobs:
1010
name: publish documentation
1111
steps:
1212
- uses: actions/checkout@v4
13-
- name: Setup Python
14-
uses: actions/setup-python@v4
13+
- name: Install uv
14+
uses: astral-sh/setup-uv@v5
1515
with:
1616
python-version: '3.10'
17-
18-
- name: install dependencies pip
19-
run: |
20-
python3 -m pip install -U pip
21-
python3 -m pip install .[doc]
17+
18+
- name: Install the project
19+
run:
20+
uv sync --group=doc
21+
2222

2323
- name: make docs
2424
run: |
25-
make -C docs clean
26-
make -C docs html
27-
25+
cd docs
26+
uv run --no-sync make html
27+
2828
- name: Init repo for generated files
2929
run: |
3030
cd docs/_build/html

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ sdist:
7070
tags:
7171
- docker
7272

73-
flake8:
73+
ruff-lint:
7474
stage: static-analysis
7575
image: pytorch/pytorch:2.2.0-cuda11.8-cudnn8-devel
7676
before_script:
7777
- *default-before-script
7878
- uv sync --only-group=dev
7979
script:
80-
- uv run --no-sync make check-flake8
80+
- uv run --no-sync make check-ruff-lint
8181
tags:
8282
- docker
8383

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ help: ## Show this message
1515

1616

1717
# Check style and linting
18-
.PHONY: check-ruff-format check-ruff-organize-imports check-flake8 check-mypy static-analysis
18+
.PHONY: check-ruff-format check-ruff-organize-imports check-ruff-lint check-mypy static-analysis
1919

2020
check-ruff-format: ## Run ruff format checks
2121
@echo "--> Running ruff format checks"
@@ -25,15 +25,15 @@ check-ruff-organize-imports: ## Run ruff organize imports checks
2525
@echo "--> Running ruff organize imports checks"
2626
@ruff check --ignore ALL --select I $(src_dirs)
2727

28-
check-flake8: ## Run flake8 checks
29-
@echo "--> Running flake8 checks"
30-
@flake8 $(src_dirs)
28+
check-ruff-lint: ## Run ruff lint checks
29+
@echo "--> Running ruff lint checks"
30+
@ruff check $(src_dirs)
3131

3232
check-mypy: ## Run mypy checks
3333
@echo "--> Running mypy checks"
3434
@mypy
3535

36-
static-analysis: check-ruff-format check-ruff-organize-imports check-flake8 # check-mypy ## Run all static checks
36+
static-analysis: check-ruff-format check-ruff-organize-imports check-ruff-lint # check-mypy ## Run all static checks
3737

3838

3939
# Apply styling

compressai/entropy_models/entropy_models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,9 +847,9 @@ def _build_cdf(self, scales, means, weights, abs_max):
847847
),
848848
dim=1,
849849
).transpose(0, 1)
850-
pmf_quantized[
851-
pmf_real_steal_indices[0], pmf_real_steal_indices[1]
852-
] -= pmf_zero_count
850+
pmf_quantized[pmf_real_steal_indices[0], pmf_real_steal_indices[1]] -= (
851+
pmf_zero_count
852+
)
853853

854854
cdf = F.pad(torch.cumsum(pmf_quantized, 1).int(), (1, 0), "constant", 0)
855855
cdf = F.pad(cdf, (0, 1), "constant", cdf_limit + 1)

ruff.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@ extend-exclude = [
22
"*.ipynb",
33
]
44

5+
[lint]
6+
select = ["E", "F"]
7+
ignore = ["E203", "E501", "F401", "F403"]
8+
# E203, black and flake8 disagree on whitespace before ':'
9+
# E501, line too long (> 79 characters)
10+
# W503, black and flake8 disagree on how to place operators
11+
# F403, 'from module import *' used; unable to detect undefined names
12+
513
[lint.isort]
614
lines-between-types = 1
715
known-third-party = [
816
"PIL",
917
"pytorch_msssim",
1018
"torchvision",
1119
"torch",
12-
]
20+
]

0 commit comments

Comments
 (0)