From 3590d86e173f55392ac940b011ad428c8bcdcfbd Mon Sep 17 00:00:00 2001 From: Jack Cherng Date: Sat, 17 Feb 2024 03:21:39 +0800 Subject: [PATCH] chore: replace pip with uv Signed-off-by: Jack Cherng --- .github/workflows/python.yml | 34 +++++++++++++++---------------- Makefile | 22 ++++++++++++++------ pyproject.toml | 29 ++++++--------------------- requirements.in | 10 +++++++++ requirements.txt | 39 +++++++++++++++++++++++------------- 5 files changed, 74 insertions(+), 60 deletions(-) create mode 100644 requirements.in diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 485190d..2056ad9 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -6,45 +6,45 @@ name: Python on: push: branches: - - "**" + - '**' paths: - - ".github/workflows/python.yml" - - "**.py" - - "**.pyi" - - "Makefile" + - '.github/workflows/python.yml' + - '**.py' + - '**.pyi' + - 'Makefile' pull_request: branches: - - "**" + - '**' paths: - - ".github/workflows/python.yml" - - "**.py" - - "**.pyi" - - "Makefile" + - '.github/workflows/python.yml' + - '**.py' + - '**.pyi' + - 'Makefile' jobs: job_lint: - name: Linting (Python ${{ matrix.python-version }}) + name: ${{ matrix.python-version }} runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-latest"] - python-version: ["3.8"] + os: ['ubuntu-latest'] + python-version: ['3.8'] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip wheel - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + python -m pip install -U uv + make UV_INSTALL_FLAGS="--system" install - name: Do linting run: | diff --git a/Makefile b/Makefile index 2449cbd..2aca929 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,28 @@ +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 1179fd0..fe7b0f7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,24 +9,6 @@ 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 = [ @@ -43,18 +25,15 @@ pythonVersion = '3.8' [tool.ruff] preview = true -select = ["E", "F", "W", "I", "UP"] -ignore = ["E203"] line-length = 120 target-version = 'py38' exclude = [ + "*/libs/*", ".git", ".mypy_cache", ".venv", ".venv-*", "branch-*", - "libs", - "plugin/libs", "stubs", "tests/files", "typings", @@ -63,5 +42,9 @@ exclude = [ "venv-*", ] -[tool.ruff.per-file-ignores] +[tool.ruff.lint] +select = ["E", "F", "W", "I", "UP"] +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..a0c5469 --- /dev/null +++ b/requirements.in @@ -0,0 +1,10 @@ +mypy +ruff>=0.3 + +# ----------- # +# for scripts # +# ----------- # + +fire +requests +tinycss2 diff --git a/requirements.txt b/requirements.txt index b0c036e..2f9aecd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,25 @@ -# This is an implicit value, here for clarity ---index https://pypi.python.org/simple/ - -black -mypy -ruff - -# ----------- # -# for scripts # -# ----------- # - -fire -requests -tinycss2 +# This file was autogenerated by uv via the following command: +# uv pip compile requirements.in -o requirements.txt +certifi==2024.2.2 + # via requests +charset-normalizer==3.3.2 + # via requests +fire==0.6.0 +idna==3.6 + # via requests +mypy==1.9.0 +mypy-extensions==1.0.0 + # via mypy +requests==2.31.0 +ruff==0.3.4 +six==1.16.0 + # via fire +termcolor==2.4.0 + # via fire +tinycss2==1.2.1 +typing-extensions==4.10.0 + # via mypy +urllib3==2.2.1 + # via requests +webencodings==0.5.1 + # via tinycss2