Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Commit

Permalink
Toml profiles + Python 3.10 (Toufool#140)
Browse files Browse the repository at this point in the history
* Typings update

* Full setup and configuration update

* User Profile, Revamped settings, Start image fixes & __auto_splitter method refactor
  • Loading branch information
Avasam authored Sep 3, 2022
1 parent 88d7d6a commit 6b928ca
Show file tree
Hide file tree
Showing 44 changed files with 1,767 additions and 2,003 deletions.
25 changes: 14 additions & 11 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
[flake8]
color=always
max-line-length=120
exclude=
src/gen/, ; Auto generated
typings/cv2-stubs/__init__.pyi, ; External existing stub
; Auto generated
exclude=src/gen/, typings/cv2-stubs/__init__.pyi
ignore=
W503, ; Linebreak before binary operator
E402, ; Allow imports at the bottom of file
Y026, ; Not using typing_extensions
W503, ; Linebreak before binary operator
E402, ; Allow imports at the bottom of file
Y026, ; Not using typing_extensions
SIM105, ; contextlib.suppress is roughly 3x slower than try/except
CCE001, ; False positives for attribute docstrings
per-file-ignores=
; Docstrings in type stubs
; Function bodys contain other than just ... (eg: raise)
; Single quote docstrings
typings/cv2-stubs/__init__.pyi: Q000,N8,E704, Y021,Y010,Q002

typings/cv2-stubs/__init__.pyi: Q000,E704,E501,N8,A002,A003,CCE002,F401, Y021,Y010,Q002
; Quotes
; Allow ... on same line as def
; Line too long
; Naming conventions can't be controlled for external libraries
typings/**: Q000,E704,E501,N8

; Argument names can't be controlled for external libraries
; attribute names can't be controlled for external libraries
; False positive Class level expression with elipsis
; Type re-exports
*.pyi: Q000,E704,E501,N8,A002,A003,CCE002,F401
; PyQt methods
ignore-names=closeEvent,paintEvent,keyPressEvent,mousePressEvent,mouseMoveEvent,mouseReleaseEvent
; McCabe max-complexity is also taken care of by Pylint and doesn't fail the build there
; So this is the hard limit
max-complexity=32
inline-quotes="
inline-quotes=double
136 changes: 70 additions & 66 deletions .github/workflows/lint-and-build.yml
Original file line number Diff line number Diff line change
@@ -1,130 +1,134 @@
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
name: Lint and build
on:
workflow_dispatch: # Allows manual builds
push:
branches:
- main
- master
- 2.0.0
paths:
- '**.py'
- '**.pyi'
- '**.ui'
- "**.py"
- "**.pyi"
- "**.ui"
pull_request:
branches:
- main
- master
- dev
- dev*
- 2.0.0
paths:
- '**.py'
- '**.pyi'
- '**.ui'
- "**.py"
- "**.pyi"
- "**.ui"

env:
GITHUB_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}

jobs:
Pyright:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.9", "3.10"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r "scripts/requirements.txt"
npm install -g pyright
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Pyright
run: pyright --warnings
Pylint:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.9", "3.10"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py')
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Pylint
run: pylint --reports=y --output-format=colorized src/
Flake8:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.9", "3.10"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Flake8
run: flake8
Bandit:
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r "scripts/requirements.txt"
- run: scripts/compile_resources.bat
- name: Analysing the code with ${{ job.name }}
python-version: "3.10"
cache: "pip"
cache-dependency-path: "scripts/requirements*.txt"
- run: scripts/install.ps1
shell: pwsh
- name: Analysing the code with Bandit
run: bandit -n 1 --severity-level medium --recursive src
Build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.10"]
steps:
- name: Checkout ${{ github.repository }}/${{ github.ref }}
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
pip install -r "scripts/requirements.txt"
- run: scripts/build.bat
cache: "pip"
- run: scripts/install.ps1
shell: pwsh
- run: scripts/build.ps1
shell: pwsh
- name: Upload Build Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: AutoSplit (Python ${{ matrix.python-version }})
path: dist/AutoSplit.exe
path: dist/AutoSplit*
if-no-files-found: error
- name: Upload Build logs
uses: actions/upload-artifact@v3
with:
name: Build logs (Python ${{ matrix.python-version }})
path: |
build/AutoSplit/*.toc
build/AutoSplit/*.txt
build/AutoSplit/*.html
if-no-files-found: error
15 changes: 14 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@
"bungcip.better-toml",
"davidanson.vscode-markdownlint",
"eamodio.gitlens",
"ms-python.flake8",
"ms-python.python",
"ms-python.vscode-pylance",
"ms-vscode.powershell",
"pkief.material-icon-theme",
"redhat.vscode-yaml",
"shardulm94.trailing-spaces",
"sonarsource.sonarlint-vscode"
],
"unwantedRecommendations": [
// Must disable in this workspace //
//
// VSCode has implemented an optimized version
"coenraads.bracket-pair-colorizer",
"coenraads.bracket-pair-colorizer-2",
Expand All @@ -21,7 +26,15 @@
"ms-vscode.vscode-typescript-tslint-plugin",
// Obsoleted by Pylance
"ms-pyright.pyright",
// The ESLint plugin is sufficient in JS-only projects
// Not configurable per workspace, tends to conflict with other linters
// Use eslint-plugin-sonarjs for JS/TS projects
"sonarsource.sonarlint-vscode",
//
// Don't recommend to autoinstall //
//
// This is a Git project
"johnstoncode.svn-scm",
// Prefer using VSCode itself as a text editor
"vscodevim.vim",
]
}
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: AutoSplit",
"type": "python",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Python: AutoSplit --auto-controlled",
"type": "python",
"request": "launch",
"preLaunchTask": "Compile resources",
"program": "src/AutoSplit.py",
"args": [
"--auto-controlled"
],
"console": "integratedTerminal",
"justMyCode": true
}
]
}
54 changes: 42 additions & 12 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
"markdown"
],
"files.associations": {
"*.json": "json",
"extensions.json": "jsonc",
"settings.json": "jsonc",
"*.qrc": "xml",
"*.ui": "xml"
},
Expand All @@ -39,10 +42,9 @@
"**/__pycache__": true,
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"typings": true,
"*.lock": true,
},
"[python]": {
"editor.tabSize": 4,
Expand All @@ -52,21 +54,42 @@
// 88, // Black default
99, // PEP8-17 acceptable max
120, // Our hard rule
]
],
},
"python.analysis.diagnosticMode": "workspace",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.pylintCategorySeverity.convention": "Warning",
"python.linting.pylintCategorySeverity.refactor": "Warning",
"python.linting.flake8Enabled": true,
// pycodestyles
"python.linting.flake8CategorySeverity.E": "Warning",
// Pyflakes
"python.linting.flake8CategorySeverity.F": "Warning",
// PEP8 Naming convention
"python.linting.flake8CategorySeverity.N": "Warning",
// PYI
"python.linting.flake8CategorySeverity.Y": "Warning",
// Use the new Flake8 extension instead
"python.linting.flake8Enabled": false,
"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",
// 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
Expand All @@ -76,4 +99,11 @@
// Just another wrapper, use Flake8 OR this
"python.linting.pylamaEnabled": false,
"python.linting.banditEnabled": true,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.codeFormatting.autoCorrectAliases": true,
"powershell.codeFormatting.trimWhitespaceAroundPipe": true,
"powershell.codeFormatting.useConstantStrings": true,
"powershell.codeFormatting.useCorrectCasing": true,
"powershell.codeFormatting.whitespaceBetweenParameters": true,
"powershell.integratedConsole.showOnStartup": false,
}
Loading

0 comments on commit 6b928ca

Please sign in to comment.