From bcb0f173ef2d4948eddf583f86064ee3d2fc3d8e Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Fri, 16 Feb 2024 23:43:59 +0800 Subject: [PATCH] chore: replace pip with uv Signed-off-by: Jack Cherng --- .github/workflows/python.yml | 11 +++--- Makefile | 23 +++++++++--- pyproject.toml | 71 ++++++++++++++++-------------------- requirements.in | 2 + requirements.txt | 16 +++++--- 5 files changed, 66 insertions(+), 57 deletions(-) create mode 100644 requirements.in diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index da18f78..a0adbae 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -11,6 +11,7 @@ on: - '.github/workflows/python.yml' - '**.py' - '**.pyi' + - 'Makefile' pull_request: branches: - '**' @@ -18,6 +19,7 @@ on: - '.github/workflows/python.yml' - '**.py' - '**.pyi' + - 'Makefile' jobs: job_lint: @@ -30,20 +32,19 @@ jobs: python-version: ['3.8'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel - pip install -r requirements.txt + python -m pip install -U uv - name: Do linting run: | - make ci-check + make UV_INSTALL_FLAGS="--system" install ci-check diff --git a/Makefile b/Makefile index 2449cbd..ee87c9b 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,29 @@ +UV_INSTALL_FLAGS := + + .PHONY: all all: .PHONY: install install: - python -m pip install -U pip -r requirements.txt + uv pip install $(UV_INSTALL_FLAGS) -r requirements.txt + +.PHONY: pip-compile +pip-compile: + uv pip compile --upgrade requirements.in -o requirements.txt .PHONY: ci-check ci-check: + @echo "========== check: mypy ==========" mypy -p plugin - ruff check --diff --preview . - black --diff --preview --check . + @echo "========== check: ruff (lint) ==========" + ruff check --diff . + @echo "========== check: ruff (format) ==========" + ruff format --diff . .PHONY: ci-fix ci-fix: - ruff check --preview --fix . - # ruff format --preview . - black --preview . + @echo "========== fix: ruff (lint) ==========" + ruff check --fix . + @echo "========== fix: ruff (format) ==========" + ruff format . diff --git a/pyproject.toml b/pyproject.toml index 8f26a2a..8cf2a17 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,33 +9,15 @@ module = ["plugin.libs.*"] ignore_errors = true ignore_missing_imports = true -[tool.black] -preview = true -line-length = 120 -target-version = ['py38'] -exclude = ''' -/( - \.git - | \.?venv - | \.mypy_cache - | br-.* - | branch-.* - | libs - | stubs - | tests/files - | typings -)/ -''' - [tool.pyright] include = ['./'] exclude = [ - '**/__pycache__/', - '**/node_modules/', - # git-related - '**/.git/', - '**/br-*/', - '**/branch-*/', + '**/__pycache__/', + '**/node_modules/', + # git-related + '**/.git/', + '**/br-*/', + '**/branch-*/', ] ignore = ['**/.venv', '**/libs'] stubPath = 'typings' @@ -43,25 +25,34 @@ pythonVersion = '3.8' [tool.ruff] preview = true -select = ["E", "F", "W", "I", "UP"] -ignore = ["E203"] line-length = 120 target-version = 'py38' exclude = [ - ".git", - ".mypy_cache", - ".venv", - ".venv-*", - "branch-*", - "libs", - "plugin/libs", - "stubs", - "tests/files", - "typings", - "vendor", - "venv", - "venv-*", + "*/libs/*", + ".git", + ".mypy_cache", + ".venv", + ".venv-*", + "branch-*", + "stubs", + "tests/files", + "typings", + "vendor", + "venv", + "venv-*", ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint] +select = [ + "E", + "F", + "W", + "I", + "UP", + "FURB", + # "SIM", +] +ignore = ["E203"] + +[tool.ruff.lint.per-file-ignores] "boot.py" = ["E402"] diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..03d5e6c --- /dev/null +++ b/requirements.in @@ -0,0 +1,2 @@ +mypy +ruff>=0.6 diff --git a/requirements.txt b/requirements.txt index 350988b..d65a1a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,10 @@ -# This is an implicit value, here for clarity ---index https://pypi.python.org/simple/ - -black -mypy -ruff +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in -o requirements.txt +mypy==1.13.0 + # via -r requirements.in +mypy-extensions==1.0.0 + # via mypy +ruff==0.7.1 + # via -r requirements.in +typing-extensions==4.12.2 + # via mypy