Skip to content

Commit

Permalink
Rebase pip-based mypy setup on uv
Browse files Browse the repository at this point in the history
  • Loading branch information
kdeldycke committed May 23, 2024
1 parent 43ecca9 commit 0182a50
Showing 1 changed file with 17 additions and 25 deletions.
42 changes: 17 additions & 25 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,38 +94,30 @@ jobs:
cache: "pip"
cache-dependency-path: |
**/pyproject.toml
*requirements.txt
requirements/*.txt
- name: Install pip
- name: Install uv
run: |
python -m pip install --upgrade pip
python -m pip install uv
- name: Install Mypy
run: >
python -m pip install --requirement
https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/mypy.txt
- name: Install Poetry
if: fromJSON(needs.project-metadata.outputs.is_poetry_project)
run: >
python -m pip install --requirement
https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/build.txt
- name: Install dependencies with Poetry
# Install project with Poetry if supported, so we can benefits from dependencies on typing stubs.
if: fromJSON(needs.project-metadata.outputs.is_poetry_project)
run: |
poetry install --all-extras --with typing --no-interaction
- name: Install dependencies with pip
if: ${{ ! fromJSON(needs.project-metadata.outputs.is_poetry_project) }}
run: >
python -m pip install --requirement
https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements.txt
- name: Run Poetry's Mypy
uv venv --system
uv pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/mypy.txt
- name: Install package with Poetry
# Install Poetry, then install the package with it, as uv cannot read Poetry-flavored pyproject.toml.
if: fromJSON(needs.project-metadata.outputs.is_poetry_project)
run: >
poetry run mypy ${{ needs.project-metadata.outputs.mypy_params }}
${{ needs.project-metadata.outputs.python_files }}
- name: Run vanilla Mypy
run: |
uv pip install -r https://raw.githubusercontent.com/kdeldycke/workflows/main/requirements/build.txt
poetry install --all-extras --with typing --with test --no-interaction
- name: Install package with uv
if: ${{ ! fromJSON(needs.project-metadata.outputs.is_poetry_project) }}
# --color-output - Force colorized output as in CI, Mypy defaults to no color.
run: |
uv pip install --requirement ./*requirements.txt
- name: Run Mypy
# We can use the bare mypy CLI for both Poetry and non-Poetry projects after activating the venv.
# --color-output - Force colorized output as in CI, Mypy defaults to no color in CI.
run: >
source .venv/bin/activate &&
mypy --color-output ${{ needs.project-metadata.outputs.mypy_params }}
${{ needs.project-metadata.outputs.python_files }}
Expand Down

0 comments on commit 0182a50

Please sign in to comment.