Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurZucker committed Jan 19, 2024
1 parent 8f9b945 commit 20c4e82
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions bindings/python/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ check_dirs := examples py_src/tokenizers tests
# Format source code automatically
style:
python stub.py
black --line-length 119 --target-version py35 $(check_dirs)
ruff check $(check_dirs) --fix
ruff format --line-length 119 --target-version py35 $(check_dirs)

# Check the source code is formatted correctly
check-style:
python stub.py --check
black --check --line-length 119 --target-version py35 examples py_src/tokenizers tests
ruff check examples py_src/tokenizers tests
ruff format --check --line-length 119 --target-version py35 examples py_src/tokenizers tests

TESTS_RESOURCES = $(DATA_DIR)/small.txt $(DATA_DIR)/roberta.json

Expand Down
9 changes: 9 additions & 0 deletions bindings/python/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ def py_file(module, origin):
string += f"{name} = {origin}.{name}\n"
return string

import subprocess
from typing import List, Optional, Tuple

def do_ruff(code):
command = ["ruff", "format", "-", "--config", "pyproject.toml", "--silent"]
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
stdout, _ = process.communicate(input=code.encode())
return stdout.decode()


def do_black(content, is_pyi):
mode = black.Mode(
Expand Down

0 comments on commit 20c4e82

Please sign in to comment.