File tree 8 files changed +260
-3
lines changed
8 files changed +260
-3
lines changed Original file line number Diff line number Diff line change
1
+ [flake8]
2
+ doctests = True
3
+ ignore =
4
+ # W503 and W504 are mutually exclusive, so one or the other must be ignored.
5
+ # PEP 8 recommends line break before, so we keep W504.
6
+ W503
7
+ max-complexity = 10
8
+ max-line-length = 120
9
+ select = E,W,F,C,N
Original file line number Diff line number Diff line change
1
+ name : Lint Python code
2
+
3
+ on :
4
+ push :
5
+ paths :
6
+ - " **.py"
7
+ - " .flake8"
8
+ - " pyproject.toml"
9
+ - " Taskfile.yml"
10
+ pull_request :
11
+ paths :
12
+ - " **.py"
13
+ - " .flake8"
14
+ - " pyproject.toml"
15
+ - " Taskfile.yml"
16
+
17
+ jobs :
18
+ lint-python :
19
+ runs-on : ubuntu-latest
20
+
21
+ steps :
22
+ - name : Checkout
23
+ uses : actions/checkout@v2
24
+
25
+ - name : Install Taskfile
26
+ uses : arduino/setup-task@v1
27
+ with :
28
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
29
+ version : 3.x
30
+
31
+ - name : Install Python
32
+ uses : actions/setup-python@v2
33
+ with :
34
+ python-version : " 3.8"
35
+
36
+ - name : Install Poetry
37
+ run : pip install poetry
38
+
39
+ - name : Lint Python files
40
+ run : task python:check
Original file line number Diff line number Diff line change 56
56
- " '{{.GOLINTBIN}}' {{.GOLINTFLAGS}} ./..."
57
57
- task : docs:check
58
58
- task : config:check
59
+ - task : python:check
59
60
60
61
config:check :
61
62
desc : Check linting of configuration and supporting files
@@ -67,6 +68,22 @@ tasks:
67
68
cmds :
68
69
- npx {{ .PRETTIER }} --write "**/*.{yml,yaml}"
69
70
71
+ python:check :
72
+ cmds :
73
+ - task : python:lint
74
+
75
+ python:lint :
76
+ desc : Lint Python code
77
+ cmds :
78
+ - poetry install --no-root
79
+ - poetry run flake8
80
+
81
+ python:format :
82
+ desc : Automatically formats Python files
83
+ cmds :
84
+ - poetry install --no-root
85
+ - poetry run black .
86
+
70
87
vars :
71
88
PROJECT_NAME : " FirmwareUploader"
72
89
DIST_DIR : " dist"
Original file line number Diff line number Diff line change @@ -307,6 +307,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
307
307
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 /go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc =
308
308
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 /go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc =
309
309
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac /go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc =
310
+ golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs =
310
311
golang.org/x/lint v0.0.0-20190930215403-16217165b5de /go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc =
311
312
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6 /go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE =
312
313
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028 /go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o =
Original file line number Diff line number Diff line change @@ -9,3 +9,11 @@ python = "^3.8"
9
9
pytest = " 6.1.2"
10
10
invoke = " ^1.5.0"
11
11
semver = " ^2.13.0"
12
+
13
+ [tool .poetry .dev-dependencies ]
14
+ flake8 = " ^3.9.2"
15
+ black = " ^21.5b1"
16
+
17
+ [tool .black ]
18
+ line-length = 120
19
+ target-version = [" py38" ]
Original file line number Diff line number Diff line change 17
17
18
18
import pathlib
19
19
import platform
20
- import invoke .context
20
+ import invoke .context
21
21
import pytest
22
22
23
+
23
24
@pytest .fixture (scope = "function" )
24
25
def run_command (pytestconfig , working_dir ):
25
26
"""Provide a wrapper around invoke's `run` API so that every test will work in the same temporary folder.
@@ -56,4 +57,4 @@ def working_dir(tmpdir_factory):
56
57
end. This way all the tests work in isolation.
57
58
"""
58
59
work_dir = tmpdir_factory .mktemp (basename = "FirmwareUploaderTestWork" )
59
- yield str (work_dir )
60
+ yield str (work_dir )
You can’t perform that action at this time.
0 commit comments