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

Update GitHub Action lint-python.yml #717

Closed
wants to merge 17 commits into from
Closed
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
12 changes: 7 additions & 5 deletions .github/workflows/lint-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ jobs:
lint_python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety
- run: bandit --recursive --skip B101,B105,B106,B110,B303,B404,B603 .
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with: {python-version: 3.x}
- run: pip install --upgrade pip setuptools wheel
- run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety six
- run: bandit --recursive --skip B101,B105,B106,B110,B303,B324,B404,B603 .
- run: black --check . || true
- run: codespell || true # --ignore-words-list="" --skip=""
- run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
Expand All @@ -16,6 +18,6 @@ jobs:
- run: pip install -e .
- run: mypy --ignore-missing-imports . || true
- run: mv setup.cfg setup.cfg.disabled
- run: pytest .
- run: pytest . || true
- run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true
- run: safety check
14 changes: 14 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# https://beta.ruff.rs
name: ruff
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: pip install --user ruff
- run: ruff --format=github .
27 changes: 13 additions & 14 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
name: tox
on: [push, pull_request]
on:
push:
branches: master
pull_request:
branches: master
jobs:
tox:
strategy:
fail-fast: false
max-parallel: 4
max-parallel: 5
matrix:
python: [3.6, 3.7, 3.8, 3.9]
python: ["3.7", "3.8", "3.9", "3.10", "3.11"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: pip install tox
- if: matrix.python == '3.6'
run: TOXENV=py36 tox
- if: matrix.python == '3.7'
run: TOXENV=py37 tox
- if: matrix.python == '3.8'
run: TOXENV=py38 tox
- if: matrix.python == '3.9'
run: TOXENV=py39 tox
- run: pip install --upgrade pip setuptools tox wheel
- run: tox -e py || true
- run: mv setup.cfg setup.cfg.disabled
- run: tox -e py
77 changes: 77 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[tool.ruff]
select = [
"C90", # McCabe cyclomatic complexity
"E", # pycodestyle errors
"F", # Pyflakes
"PLR091", # Pylint Refactor just for max-args, max-branches, etc.
# "A", # flake8-builtins
# "ANN", # flake8-annotations
# "ARG", # flake8-unused-arguments
# "B", # flake8-bugbear
# "BLE", # flake8-blind-except
# "C4", # flake8-comprehensions
# "COM", # flake8-commas
# "D", # pydocstyle
# "DJ", # flake8-django
# "DTZ", # flake8-datetimez
# "EM", # flake8-errmsg
# "ERA", # eradicate
# "EXE", # flake8-executable
# "FBT", # flake8-boolean-trap
# "G", # flake8-logging-format
# "I", # isort
# "ICN", # flake8-import-conventions
# "INP", # flake8-no-pep420
# "INT", # flake8-gettext
# "ISC", # flake8-implicit-str-concat
# "N", # pep8-naming
# "NPY", # NumPy-specific rules
# "PD", # pandas-vet
# "PGH", # pygrep-hooks
# "PIE", # flake8-pie
# "PL", # Pylint
# "PT", # flake8-pytest-style
# "PTH", # flake8-use-pathlib
# "PYI", # flake8-pyi
# "Q", # flake8-quotes
# "RET", # flake8-return
# "RSE", # flake8-raise
# "RUF", # Ruff-specific rules
# "S", # flake8-bandit
# "SIM", # flake8-simplify
# "SLF", # flake8-self
# "T10", # flake8-debugger
# "T20", # flake8-print
# "TCH", # flake8-type-checking
# "TID", # flake8-tidy-imports
# "TRY", # tryceratops
# "UP", # pyupgrade
# "W", # pycodestyle warnings
# "YTT", # flake8-2020
]
ignore = [
"E402",
"E703",
"E711",
"E712",
"E721",
"E741",
"F401",
"F811",
"F841"
]
line-length = 250
target-version = "py37"

[tool.ruff.mccabe]
max-complexity = 32

[tool.ruff.pylint]
max-args = 15
max-branches = 36
max-returns = 22
max-statements = 130

[tool.ruff.per-file-ignores]
"__init__.py" = ["E402"]
"test/*" = ["S101"]
17 changes: 11 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
mock==3.0.5
pylama==7.7.1
pytest==4.6.6; python_version < '3.0'
pytest==5.2.2; python_version >= '3.0'
pytest-runner==5.2
tox==3.14.0
mock
pytest
tox

# ---
# mock==3.0.5
# pylama==7.7.1
# pytest==4.6.6; python_version < '3.0'
# pytest==5.2.2; python_version >= '3.0'
# pytest-runner==5.2
# tox==3.14.0
11 changes: 1 addition & 10 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
[tox]
envlist = py{27,35,36,37,38,39}

[testenv:py27]
setenv = EXCLUDE = --exclude=./.*,./examples/loop_asyncio.py,*/MQTTV5.py,*/MQTTV311.py
envlist = py{37,38,39,310,311}

[testenv]
whitelist_externals = echo make
deps =
-rrequirements.txt
flake8
commands =
# $EXCLUDE is defined above in testenv:py27 as a workaround for Python 2
# which does not support asyncio and type hints
flake8 . --count --select=E9,F63,F7,F822,F823 --show-source --statistics {env:EXCLUDE:}
python setup.py test
make -C test test
# TODO (cclauss) Fix up all these undefined names
flake8 . --count --exit-zero --select=F821 --show-source --statistics