Skip to content

Commit 09b34fc

Browse files
committed
Configured linting workflow
1 parent 3f23c55 commit 09b34fc

29 files changed

+3577
-3348
lines changed

.flake8

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[flake8]
22
color=always
33
max-line-length=120
4-
; TODO: Bring WAY down
5-
max-complexity=55
64
; Auto generated
75
exclude=src/gen/
86
; TODO: We want to configure this
@@ -12,3 +10,6 @@ per-file-ignores =
1210
; line too long
1311
; mixed case
1412
__init__.pyi:F401,E501,N816
13+
; TODO: Bring WAY down
14+
max-complexity=55
15+
inline-quotes = "

.github/workflows/build-and-lint.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
2+
name: Build and lint
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
- 2.0.0
9+
pull_request:
10+
branches:
11+
- main
12+
- master
13+
- dev
14+
- dev*
15+
jobs:
16+
Pyright:
17+
runs-on: windows-latest
18+
strategy:
19+
matrix:
20+
python-version: ["3.8", "3.9"]
21+
steps:
22+
- name: Checkout ${{ github.repository }}/${{ github.ref }}
23+
uses: actions/checkout@v2
24+
- name: Set up Node
25+
uses: actions/setup-node@v2
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: Install dependencies
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install -r "scripts/requirements.txt"
34+
npm install -g pyright
35+
- run: scripts/compile_resources.bat
36+
- name: Analysing the code with ${{ job.name }}
37+
run: pyright
38+
Pylint:
39+
runs-on: windows-latest
40+
strategy:
41+
matrix:
42+
python-version: ["3.8", "3.9"]
43+
steps:
44+
- name: Checkout ${{ github.repository }}/${{ github.ref }}
45+
uses: actions/checkout@v2
46+
- name: Set up Python ${{ matrix.python-version }}
47+
uses: actions/setup-python@v2
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install -r "scripts/requirements.txt"
54+
- run: scripts/compile_resources.bat
55+
- name: Analysing the code with ${{ job.name }}
56+
run: pylint --reports=y --output-format=colorized $(git ls-files '**/*.py*')
57+
Bandit:
58+
runs-on: windows-latest
59+
strategy:
60+
matrix:
61+
python-version: ["3.8", "3.9"]
62+
steps:
63+
- name: Checkout ${{ github.repository }}/${{ github.ref }}
64+
uses: actions/checkout@v2
65+
- name: Set up Python ${{ matrix.python-version }}
66+
uses: actions/setup-python@v2
67+
with:
68+
python-version: ${{ matrix.python-version }}
69+
- name: Install dependencies
70+
run: |
71+
python -m pip install --upgrade pip
72+
pip install -r "scripts/requirements.txt"
73+
- run: scripts/compile_resources.bat
74+
- name: Analysing the code with ${{ job.name }}
75+
run: bandit -n 1 --severity-level medium --recursive src
76+
Flake8:
77+
runs-on: windows-latest
78+
strategy:
79+
matrix:
80+
python-version: ["3.8", "3.9"]
81+
steps:
82+
- name: Checkout ${{ github.repository }}/${{ github.ref }}
83+
uses: actions/checkout@v2
84+
- name: Set up Python ${{ matrix.python-version }}
85+
uses: actions/setup-python@v2
86+
with:
87+
python-version: ${{ matrix.python-version }}
88+
- name: Install dependencies
89+
run: |
90+
python -m pip install --upgrade pip
91+
pip install -r "scripts/requirements.txt"
92+
- run: scripts/compile_resources.bat
93+
- name: Analysing the code with ${{ job.name }}
94+
run: flake8
95+
Build:
96+
runs-on: windows-latest
97+
strategy:
98+
matrix:
99+
python-version: ["3.8", "3.9"]
100+
steps:
101+
- name: Checkout ${{ github.repository }}/${{ github.ref }}
102+
uses: actions/checkout@v2
103+
- name: Set up Python ${{ matrix.python-version }}
104+
uses: actions/setup-python@v2
105+
with:
106+
python-version: ${{ matrix.python-version }}
107+
- name: Install dependencies
108+
run: |
109+
python -m pip install --upgrade pip
110+
pip install -r "scripts/requirements.txt"
111+
- run: scripts/build.bat

.mypy.ini

Lines changed: 0 additions & 33 deletions
This file was deleted.

.pylintrc

Lines changed: 0 additions & 23 deletions
This file was deleted.

.vscode/extensions.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"recommendations": [
3-
"ms-python.vscode-pylance",
4-
"ms-python.python",
5-
"sonarsource.sonarlint-vscode",
3+
"bungcip.better-toml",
64
"davidanson.vscode-markdownlint",
5+
"eamodio.gitlens",
6+
"ms-python.python",
7+
"ms-python.vscode-pylance",
78
"shardulm94.trailing-spaces",
8-
"eamodio.gitlens"
9+
"sonarsource.sonarlint-vscode"
910
],
1011
"unwantedRecommendations": [
1112
"ms-pyright.pyright",

.vscode/settings.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@
1313
"[python]": {
1414
"editor.tabSize": 4,
1515
"editor.rulers": [
16-
79,
17-
100,
18-
120,
16+
72, // PEP8-17 docstrings
17+
// 79, // PEP8-17 default max
18+
// 88, // Black default
19+
99, // PEP8-17 acceptable max
20+
120, // Our hard rule
1921
]
2022
},
2123
"editor.formatOnSave": true,
2224
"editor.codeActionsOnSave": {
2325
"source.fixAll": true,
2426
"source.fixAll.markdownlint": true,
2527
},
26-
// Set to trace when sending error reports to Pylance
27-
// "python.analysis.logLevel": "Trace",
28-
// https://code.visualstudio.com/docs/python/linting#_specific-linters
2928
"python.linting.enabled": true,
3029
"python.linting.pylintEnabled": true,
3130
"python.linting.pylintCategorySeverity.convention": "Warning",
3231
"python.linting.pylintCategorySeverity.refactor": "Warning",
3332
"python.linting.flake8Enabled": true,
3433
"python.linting.flake8CategorySeverity.E": "Warning",
35-
"python.linting.mypyEnabled": true,
34+
// PyRight obsoletes mypy
35+
"python.linting.mypyEnabled": false,
3636
// Is already wrapped by Flake8, prospector and pylama
3737
"python.linting.pycodestyleEnabled": false,
3838
// Just another wrapper, use Flake8 OR this
@@ -66,5 +66,5 @@
6666
"**/bower_components": true,
6767
"**/*.code-search": true,
6868
"typings": true,
69-
}
69+
},
7070
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!-- markdownlint-disable-next-line MD033 -->
2-
# <img src="res/icon.ico" alt="LiveSplit" height="42" width="42" align="top"/> AutoSplit
2+
# <img src="res/icon.ico" alt="LiveSplit" height="42" width="42" align="top"/> AutoSplit [![Build and lint](/../../actions/workflows/build-and-lint.yml/badge.svg)](/../../actions/workflows/build-and-lint.yml) [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=reliability_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split) [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=security_rating)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split) [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=Avasam_Auto-Split&metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=Avasam_Auto-Split)
33

44
Easy to use image comparison based auto splitter for speedrunning on console or PC.
55

pyproject.toml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# https://black.readthedocs.io/en/stable/usage_and_configuration/the_basics.html#configuration-via-a-file
2+
[tool.black]
3+
line-length = 120
4+
# Auto generated
5+
force-exclude = "src/gen/.*\\.py$"
6+
7+
# https://github.com/hhatto/autopep8#usage
8+
# https://github.com/hhatto/autopep8#more-advanced-usage
9+
[tool.autopep8]
10+
max_line_length = 120
11+
recursive = true
12+
aggressive = 3
13+
14+
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md#sample-pyprojecttoml-file
15+
[tool.pyright]
16+
pythonPlatform = "Windows"
17+
typeCheckingMode = "strict"
18+
stubPath = "typings/"
19+
ignore = [
20+
# Auto generated
21+
"src/gen/",
22+
"typings/",
23+
]
24+
reportMissingTypeStubs = "information"
25+
# False positives with TYPE_CHECKING
26+
reportImportCycles = "information"
27+
# PyQt .connect
28+
reportFunctionMemberAccess = "information"
29+
# Extra runtime safety
30+
reportUnnecessaryComparison = "warning"
31+
# Flake8 does a better job
32+
reportUnusedImport = "none"
33+
# numpy has way too many complex types that triggers this
34+
reportUnknownMemberType = "none"
35+
36+
# https://github.com/PyCQA/pylint/blob/main/examples/pylintrc
37+
# https://pylint.pycqa.org/en/latest/technical_reference/features.html
38+
[tool.pylint.REPORTS]
39+
# Just like default but any error will make drop to 9 or less
40+
evaluation="10.0 - error - ((float(warning + refactor + convention) / statement) * 10)"
41+
[tool.pylint.MASTER]
42+
fail-under=9.0
43+
# https://pylint.pycqa.org/en/latest/technical_reference/extensions.html
44+
load-plugins = [
45+
"pylint.extensions.emptystring",
46+
"pylint.extensions.confusing_elif",
47+
"pylint.extensions.consider_ternary_expression",
48+
"pylint.extensions.bad_builtin",
49+
"pylint.extensions.mccabe",
50+
"pylint.extensions.check_elif",
51+
"pylint.extensions.redefined_variable_type",
52+
"pylint.extensions.overlapping_exceptions",
53+
"pylint.extensions.empty_comment",
54+
"pylint.extensions.set_membership",
55+
"pylint.extensions.typing",
56+
# TODO: Maybe later
57+
# "pylint.extensions.docparams",
58+
# Not wanted/needed
59+
# "pylint.extensions.broad_try_clause",
60+
# "pylint.extensions.code_style",
61+
# "pylint.extensions.comparetozero",
62+
# "pylint.extensions.docstyle",
63+
# "pylint.extensions.while_used",
64+
# Didn't work
65+
# "pylint.extensions.comparison_placement",
66+
# "pylint.extensions.for_any_all",
67+
]
68+
ignore-paths = [
69+
# Haven't looked into disabling specific rules per file
70+
"^typings/.*$",
71+
# Auto generated
72+
"^src/gen/.*$",
73+
]
74+
# No need to mention the fixmes
75+
disable=["fixme"]
76+
extension-pkg-allow-list = ["PyQt6", "win32ui"]
77+
78+
[tool.pylint.FORMAT]
79+
max-line-length = 120
80+
81+
[tool.pylint.'MESSAGES CONTROL']
82+
disable = [
83+
"missing-docstring",
84+
# TODO: We want to configure this
85+
# https://pylint.pycqa.org/en/latest/user_guide/options.html#naming-styles
86+
"invalid-name",
87+
# We group imports
88+
"wrong-import-position",
89+
# Already taken care of and grayed out. Also conflicts with Pylance reportIncompatibleMethodOverride
90+
"unused-argument",
91+
# Already taken care of by Flake8
92+
"unused-import",
93+
]
94+
95+
[tool.pylint.TYPECHECK]
96+
generated-members = "cv2"

pyrightconfig.json

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)