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

Replace flake8 + isort + bandit with ruff #770

Merged
merged 2 commits into from
Dec 22, 2023
Merged
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
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[tool.ruff]
line-length = 167

ignore = [
"E402", # TODO: enable
"E711", # TODO: enable
"E711", # TODO: enable
"E712", # TODO: enable
"E721", # TODO: enable
"S101", # TODO: enable
"S110", # TODO: enable
"S324", # TODO: enable
]
extend-select = [
"S", # Bandit
"E9",
"F63",
"F7",
"F82",
"I",
]

[tool.ruff.per-file-ignores]
"{test,tests,examples}/**/*.py" = [
"E741",
"F401",
"F811",
"F841",
"I",
"S",
]
2 changes: 0 additions & 2 deletions src/paho/mqtt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import logging
import string
import struct
import sys
import threading
import time
import uuid
Expand Down Expand Up @@ -3550,7 +3549,6 @@ def _handle_pubackcomp(self, cmd):
return MQTT_ERR_SUCCESS

def _handle_on_message(self, message):
matched = False

try:
topic = message.topic
Expand Down
1 change: 0 additions & 1 deletion src/paho/mqtt/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"""

import struct
import sys

from .packettypes import PacketTypes

Expand Down
1 change: 0 additions & 1 deletion src/paho/mqtt/reasoncodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*******************************************************************
"""

import sys

from .packettypes import PacketTypes

Expand Down
2 changes: 1 addition & 1 deletion test/paho_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def gen_connack(flags=0, rc=0, proto_ver=4, properties=b"", property_helper=True

packet = struct.pack('!BBBB', 32, 2+len(properties), flags, rc) + properties
else:
packet = struct.pack('!BBBB', 32, 2, flags, rc);
packet = struct.pack('!BBBB', 32, 2, flags, rc)

return packet

Expand Down
28 changes: 4 additions & 24 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,26 @@ envlist = py{37,38,39}
whitelist_externals = echo make
deps =
-rrequirements.txt
flake8
ruff==0.1.8
allowlist_externals =
echo
make
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:}
ruff .
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

# On older Python, flake8 version 4 fail with:
# RecursionError: maximum recursion depth exceeded
[testenv:py37]
deps =
-rrequirements.txt
flake8<4

# This lint environment should be the same as the one in .github/work
[testenv:lint]
deps =
bandit
-e .
black
codespell
flake8
isort
mypy
pytest
pyupgrade
ruff==0.1.8
safety
-e .
commands =
# The "-" in front of command tells tox to ignore errors
bandit --recursive --skip B101,B105,B106,B110,B303,B404,B603,B324 src
- black --check src
- codespell
flake8 src --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 src --count --exit-zero --max-complexity=29 --max-line-length=167 --show-source --statistics
isort --check-only --profile black src
- mypy --ignore-missing-imports src
safety check
Loading