Skip to content

Commit

Permalink
black -> ruff
Browse files Browse the repository at this point in the history
Removed black configs, added black configs under ruff, ran ruff check and applied safe fixes
  • Loading branch information
ishandeva committed Oct 6, 2024
1 parent 843b793 commit 6fd2651
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
check_dirs := optimum test bench examples

check:
black --check ${check_dirs}
ruff check ${check_dirs}

style:
black ${check_dirs}
ruff check ${check_dirs} --fix

test:
Expand Down
2 changes: 1 addition & 1 deletion external/awq/test_awq_kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# limitations under the License.
import pytest
import torch

from pack import pack_awq

from optimum.quanto import AffineQuantizer, MaxOptimizer, qint4, ungroup


Expand Down
2 changes: 1 addition & 1 deletion external/awq/test_awq_packing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import numpy as np
import pytest
import torch

from pack_intweight import pack_intweight
from packing_utils import pack_awq, reverse_awq_order, unpack_awq

from optimum.quanto import AWQPackedTensor, AWQPacking


Expand Down
2 changes: 1 addition & 1 deletion external/smoothquant/smoothquant.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from tqdm import tqdm
from transformers import AutoModelForCausalLM, AutoTokenizer
from transformers.models.bloom.modeling_bloom import BloomBlock
from transformers.models.opt.modeling_opt import OPTDecoderLayer
from transformers.models.llama.modeling_llama import LlamaDecoderLayer, LlamaRMSNorm
from transformers.models.mistral.modeling_mistral import MistralDecoderLayer, MistralRMSNorm
from transformers.models.opt.modeling_opt import OPTDecoderLayer


def get_act_scales(model, tokenizer, dataset, num_samples=512, seq_len=512):
Expand Down
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dynamic = ['version']
homepage = 'https://github.com/huggingface/optimum-quanto'

[project.optional-dependencies]
dev = ['pytest', 'ruff', 'black']
dev = ['pytest', 'ruff']
examples = [
'torchvision',
'transformers',
Expand All @@ -50,19 +50,20 @@ version = {attr = 'optimum.quanto.__version__'}
requires = ['setuptools>65.5.1', 'setuptools_scm']
build-backend = 'setuptools.build_meta'

[tool.black]
line-length = 119

[tool.ruff]
# Never enforce `E501` (line length violations).
# Configuration for Ruff
line-length = 119 # Same line-length as Black had

# Linting rules:
# Never enforce `E501` (line length violations) and other specific rules.
lint.ignore = ['C901', 'E501', 'E741']
lint.select = ['C', 'E', 'F', 'I', 'W']
line-length = 119

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

# isort configuration (to sort imports)
[tool.ruff.lint.isort]
lines-after-imports = 2
known-first-party = ['optimum.quanto']
known-first-party = ['optimum.quanto']
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ else
pip install --upgrade --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu118
fi
# Build tools
pip install black ruff pytest build
pip install ruff pytest build
# For examples
pip install accelerate transformers datasets

0 comments on commit 6fd2651

Please sign in to comment.