feat: Upgrade Python linting from flake8 to ruff (#2815)

[Ruff](https://beta.ruff.rs/) supports [over 500 lint rules](https://beta.ruff.rs/docs/rules) including bandit, isort, pylint, pyupgrade, and flake8 plus its plugins and is written in Rust for speed.

This GitHub Action will provide contributors with intuitive GitHub Annotations.

![image](https://user-images.githubusercontent.com/3709715/223758136-afc386d2-70aa-4eff-953a-2c2d82ceea23.png)

The `Required` in the checks below should be:
1. Removed from `flake8-annotation` and added to `ruff-annotation` which replaces it.
2. Removed from `isort` and added to `ruff` which replaces it.
This commit is contained in:
Christian Clauss 2023-03-13 11:43:22 +01:00 committed by GitHub
parent 39ac2c135d
commit fc0ddc6523
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View file

@ -8,6 +8,12 @@ on:
pull_request:
branches: [ main ]
jobs:
Lint_Python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --format=github --select="E,F,PLC,PLE,UP,W,YTT" --ignore="S101,UP031" --target-version=py37 .
Tests:
strategy:
fail-fast: false
@ -33,15 +39,12 @@ jobs:
- name: Install Dependencies
run: |
npm install --no-progress
pip install flake8 pytest
pip install pytest
- name: Set Windows environment
if: startsWith(matrix.os, 'windows')
run: |
echo 'GYP_MSVS_VERSION=2015' >> $Env:GITHUB_ENV
echo 'GYP_MSVS_OVERRIDE_PATH=C:\\Dummy' >> $Env:GITHUB_ENV
- name: Lint Python
if: startsWith(matrix.os, 'ubuntu')
run: flake8 . --ignore=E203,W503 --max-complexity=101 --max-line-length=88 --show-source --statistics
- name: Run Python tests
run: python -m pytest
# - name: Run doctests with pytest

View file

@ -24,7 +24,7 @@ import gyp
import gyp.common
import gyp.msvs_emulation
import shlex
import xml.etree.cElementTree as ET
import xml.etree.ElementTree as ET
generator_wants_static_library_dependencies_adjusted = False

View file

@ -2770,7 +2770,7 @@ class PBXProject(XCContainerPortal):
self.path = path
self._other_pbxprojects = {}
# super
return XCContainerPortal.__init__(self, properties, id, parent)
XCContainerPortal.__init__(self, properties, id, parent)
def Name(self):
name = self.path