Skip to content

Fix a few ruff --preview warnings #1568

Fix a few ruff --preview warnings

Fix a few ruff --preview warnings #1568

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python application
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-baseline:
runs-on: ubuntu-latest
container:
image: python:3.6.0
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
# Run as a non-root user to avoid cheribuild errors
adduser --disabled-password --gecos "Not Root" notroot
su -c "python -m pip install --user --upgrade pip" notroot
su -c " pip install --user --upgrade flake8 pytest" notroot
su -c "if [ -f requirements.txt ]; then pip install --user -r requirements.txt; fi" notroot
- name: Lint with flake8
run: |
# stop the build if there are any flake8 warnings
su -c "python -m flake8" notroot
- name: Run basic regression tests
run: su -c "tests/run_basic_tests.sh" notroot
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: |
# Use the system-provided python3 instead of actions/setup-python@v4
python3 --version
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade flake8 pytest ruff pre-commit
if [ -f requirements.txt ]; then python3 -m pip install -r requirements.txt; fi
- name: Lint with flake8
run: flake8
- name: Lint with ruff
run: ruff check .
- name: Run pre-commit checks
run: pre-commit run --all-files
- name: Run basic regression tests
run: tests/run_basic_tests.sh
build-latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade flake8 ruff pre-commit
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: flake8
- name: Lint with ruff
run: ruff check .
- name: Run pre-commit checks
run: pre-commit run --all-files
- name: Run basic regression tests
run: tests/run_basic_tests.sh
typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# Need at least python 3.8 to allow pytype to parse all the features we make use of
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade pytype
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Run pytype
run: |
pytype --config pytype.cfg --python-version 3.8 -j `nproc`