Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Ruff ! #207

Merged
merged 3 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .flake8

This file was deleted.

67 changes: 9 additions & 58 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,25 @@ env:
GITHUB_EXCLUDE_BUILD_NUMBER: ${{ inputs.excludeBuildNumber }}

jobs:
isort:
ruff:
runs-on: windows-latest
strategy:
fail-fast: false
# Ruff is version and platform sensible
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
- name: Set up Python 3.11
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with isort
run: isort src/ typings/ --check-only
- run: ruff check .
add-trailing-comma:
runs-on: windows-latest
steps:
Expand All @@ -62,19 +66,6 @@ jobs:
- run: pip install add-trailing-comma
- name: Analysing the code with add-trailing-comma
run: add-trailing-comma $(git ls-files '**.py*') --py36-plus
Bandit:
# Bandit only matters on the version deployed. Platform checks are ignored
runs-on: windows-latest
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- run: pip install bandit
- name: Analysing the code with Bandit
run: bandit src/ -n 1 --severity-level medium --recursive
Pyright:
runs-on: windows-latest
strategy:
Expand All @@ -97,46 +88,6 @@ jobs:
uses: jakebailey/pyright-action@v1
with:
working-directory: src/
Pylint:
runs-on: windows-latest
strategy:
fail-fast: false
# Pylint is version and platform sensible
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Pylint
run: pylint src/ --reports=y --output-format=colorized
Flake8:
runs-on: windows-latest
strategy:
fail-fast: false
# Flake8 is tied to the version of Python on which it runs. Platform checks are ignored
matrix:
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Flake8
run: flake8 src/ typings/
Build:
runs-on: windows-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# Caches
.cache/
.*cache/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
9 changes: 5 additions & 4 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@
"eamodio.gitlens",
"emeraldwalk.runonsave",
"ms-python.autopep8",
"ms-python.flake8",
"ms-python.isort",
"ms-python.pylint",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.powershell",
"pkief.material-icon-theme",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"shardulm94.trailing-spaces",
],
"unwantedRecommendations": [
// Must disable in this workspace //
Expand All @@ -24,13 +20,18 @@
// VSCode has implemented an optimized version
"coenraads.bracket-pair-colorizer",
"coenraads.bracket-pair-colorizer-2",
"shardulm94.trailing-spaces",
// Obsoleted by Pylance
"ms-pyright.pyright",
// Not configurable per workspace, tends to conflict with other linters
"sonarsource.sonarlint-vscode",
//
// Don't recommend to autoinstall //
//
// Use Ruff instead
"ms-python.flake8",
"ms-python.isort",
"ms-python.pylint",
// We use autopep8
"ms-python.black-formatter",
// This is a Git project
Expand Down
73 changes: 14 additions & 59 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
72
]
},
"trailing-spaces.includeEmptyLines": true,
"trailing-spaces.trimOnSave": true,
"trailing-spaces.syntaxIgnore": [
"markdown"
],
"[markdown]": {
"files.trimTrailingWhitespace": false,
},
Expand All @@ -28,14 +23,10 @@
"source.fixAll": true,
"source.fixAll.unusedImports": false,
"source.fixAll.convertImportFormat": true,
"source.organizeImports": true,
"source.organizeImports": false,
},
"emeraldwalk.runonsave": {
"commands": [
{
"match": "\\.pyi?",
"cmd": "unify ${file} --in-place --quote=\"\\\"\""
},
{
"match": "\\.pyi?",
"cmd": "add-trailing-comma ${file} --py36-plus"
Expand All @@ -62,7 +53,12 @@
"**/*.code-search": true,
"*.lock": true,
},
// Set the default formatter to help avoid Prettier
"[json][jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features",
},
"[python]": {
// Ruff is not yet a formatter: https://github.com/charliermarsh/ruff/issues/1904
// Cannot use autotpep8 until https://github.com/microsoft/vscode-autopep8/issues/32 is fixed
"editor.defaultFormatter": "ms-python.python",
"editor.tabSize": 4,
Expand All @@ -78,59 +74,18 @@
"python.analysis.useLibraryCodeForTypes": false,
"python.analysis.diagnosticMode": "workspace",
"python.formatting.provider": "autopep8",
"isort.check": true,
"isort.importStrategy": "fromEnvironment",
"python.linting.enabled": true,
// Use the new Pylint extension instead
"python.linting.pylintEnabled": false,
"pylint.severity": {
"convention": "Warning",
"error": "Error",
"fatal": "Error",
"refactor": "Warning",
"warning": "Warning",
"info": "Information"
},
// Use the new Flake8 extension instead
"ruff.importStrategy": "fromEnvironment",
// Use the Ruff extension instead
"isort.check": false,
"python.linting.banditEnabled": false,
"python.linting.flake8Enabled": false,
// Partial codes don't work yet: https://github.com/microsoft/vscode-flake8/issues/7
"flake8.severity": {
"convention": "Warning",
"error": "Error",
"fatal": "Error",
"refactor": "Warning",
"warning": "Warning",
"info": "Warning",
// builtins
"A": "Warning",
// mccabe
"C": "Warning",
// class attributes order
"CCE": "Warning",
// pycodestyles
"E": "Warning",
"E9": "Error", // Runtime
"W": "Warning",
"W6": "Error", // Deprecation warning
// Pyflakes
"F": "Warning",
// PEP8 Naming convention
"N": "Warning",
// Simplify
"SIM": "Warning",
"SIM9": "Information",
// PYI
"Y": "Warning",
},
// PyRight obsoletes mypy
"python.linting.mypyEnabled": false,
// Is already wrapped by Flake8, prospector and pylama
"python.linting.pycodestyleEnabled": false,
// Just another wrapper, use Flake8 OR this
"python.linting.prospectorEnabled": false,
// Just another wrapper, use Flake8 OR this
"python.linting.pycodestyleEnabled": false,
"python.linting.pylamaEnabled": false,
"python.linting.banditEnabled": true,
"python.linting.pylintEnabled": false,
// Use Pyright/Pylance instead
"python.linting.mypyEnabled": false,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
Expand Down
2 changes: 2 additions & 0 deletions PyInstaller/hooks/hook-requests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from PyInstaller.utils.hooks import collect_data_files

# Get the cacert.pem
Expand Down
Loading