Skip to content

Commit fe9444d

Browse files
committed
[py]: consolidate and document linting changes; enable linting in gh actions
1 parent b5b495d commit fe9444d

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

.github/workflows/ci-python.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
bazel-target-prefix: '//py'
2222

23-
tox_flake8:
23+
tox_linting:
2424
if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }}
2525
needs: check_workflow
2626
runs-on: ubuntu-latest
@@ -38,7 +38,7 @@ jobs:
3838
- name: Test with tox
3939
run: tox -c py/tox.ini
4040
env:
41-
TOXENV: flake8
41+
TOXENV: linting
4242

4343
tox_docs:
4444
if: ${{ needs.check_workflow.outputs.result == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(toJson(github.event.commits), '[run python]') == true }}

py/docs/source/index.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,16 @@ View source code online:
144144
+-----------+------------------------------------------------------+
145145
| official: | https://github.com/SeleniumHQ/selenium/tree/trunk/py |
146146
+-----------+------------------------------------------------------+
147+
148+
149+
Contributing
150+
=============
151+
152+
- Create a branch for your work
153+
- Ensure `tox` is installed (using a `virtualenv` is recommended)
154+
- `python3.7 -m venv .venv && . .venv/bin/activate && pip install tox`
155+
- After making changes, before committing execute `tox -e linting`
156+
- If tox exits `0`, commit and push otherwise fix the newly introduced breakages.
157+
- `flake8` requires manual fixes
158+
- `black` will often rewrite the breakages automatically, however the files are unstaged and should staged again.
159+
- `isort` will often rewrite the breakages automatically, however the files are unstaged and should staged again.

py/tox.ini

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ deps =
99

1010
commands = sphinx-build -b html -d ../build/doctrees docs/source ../build/docs/api/py {posargs}
1111

12-
[testenv:flake8]
13-
skip_install = true
14-
deps = flake8
15-
flake8-typing-imports
16-
commands = flake8 {posargs} --min-python-version=3.7
17-
1812

1913
[testenv:mypy]
2014
skip_install = true
@@ -35,18 +29,18 @@ profile = black
3529
py_version=37
3630
force_single_line = True
3731

38-
[testenv:isort]
39-
skip_install = true
40-
deps =
41-
isort==5.10.1
42-
commands = isort selenium/ test/
4332

44-
[testenv:black]
45-
; black is a common python code formatter. This allows us to keep code completely
46-
; consistent throughout all contributions and reduce merge conflicts in future.
47-
; Right now it is opt in and not enforced in CI but will be in future.
33+
[testenv:linting]
34+
; A consolidated linting based recipe, responsible for executing linting tools across the code base.
35+
; This encompasses isort for imports, black for general formatting and flake8.
36+
; IMPORTANT: black & isort rewrite files, flake8 merely alerts to the failure.
4837
skip_install = true
4938
deps =
39+
isort==5.10.1
5040
black==22.8.0
41+
flake8==5.0.4
42+
flake8-typing-imports==1.13.0
5143
commands =
44+
isort selenium/ test/
5245
black test/ -l 120
46+
flake8 selenium/ test/ --min-python-version=3.7

0 commit comments

Comments
 (0)