Skip to content

Commit

Permalink
chore: replace pip with uv
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
  • Loading branch information
jfcherng committed Feb 16, 2024
1 parent dacdf27 commit f4e2a40
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 58 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ on:
- '.github/workflows/python.yml'
- '**.py'
- '**.pyi'
- 'Makefile'
pull_request:
branches:
- '**'
paths:
- '.github/workflows/python.yml'
- '**.py'
- '**.pyi'
- 'Makefile'

jobs:
job_lint:
Expand All @@ -30,20 +32,21 @@ 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
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install -U uv
- name: Do linting
run: |
python -m uv v && . .venv/bin/activate
uv pip install -r requirements.txt
make ci-check
22 changes: 15 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@
all:

.PHONY: install
install:
python -m pip install -U pip -r requirements.txt
install: pip-compile
python -m uv pip install -r requirements.txt

.PHONY: pip-compile
pip-compile:
python -m uv pip compile 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 .
61 changes: 20 additions & 41 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,10 @@ strict_optional = true
mypy_path = 'typings:stubs'

[[tool.mypy.overrides]]
module = [
"plugin.libs.*",
]
module = ["plugin.libs.*"]
ignore_errors = true
ignore_missing_imports = true

[tool.black]
line-length = 120
target-version = ['py38']
exclude = '''
/(
\.git
| \.?venv
| \.mypy_cache
| br-.*
| branch-.*
| libs
| stubs
| tests/files
| typings
)/
'''

[tool.pyright]
include = ['./']
exclude = [
Expand All @@ -38,34 +19,32 @@ exclude = [
'**/br-*/',
'**/branch-*/',
]
ignore = [
'**/.venv',
'**/libs',
]
ignore = ['**/.venv', '**/libs']
stubPath = 'typings'
pythonVersion = '3.8'

[tool.ruff]
preview = true
select = ["E", "F", "W", "I"]
ignore = ["E203"]
line-length = 120
target-version = 'py312'
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"]
ignore = ["E203"]

[tool.ruff.lint.per-file-ignores]
"boot.py" = ["E402"]
2 changes: 2 additions & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mypy
ruff>=0.2
14 changes: 8 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# This is an implicit value, here for clarity
--index https://pypi.python.org/simple/

black
mypy
ruff
# This file was autogenerated by uv v0.1.2 via the following command:
# uv pip compile requirements.in -o requirements.txt
mypy==1.8.0
mypy-extensions==1.0.0
# via mypy
ruff==0.2.1
typing-extensions==4.9.0
# via mypy

0 comments on commit f4e2a40

Please sign in to comment.