Skip to content

Commit 933699a

Browse files
authored
Merge pull request #779 from akx/more-ruff
Enable more Ruff rules (incl. those `ignore`d previously)
2 parents 592a851 + 9799127 commit 933699a

14 files changed

+127
-136
lines changed

examples/client_mqtt_clear_retain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929

3030
def on_connect(mqttc, userdata, flags, rc):
31-
if userdata == True:
31+
if userdata:
3232
print("rc: " + str(rc))
3333

3434

@@ -38,7 +38,7 @@ def on_message(mqttc, userdata, msg):
3838
pass
3939
# sys.exit()
4040
else:
41-
if userdata == True:
41+
if userdata:
4242
print("Clearing topic " + msg.topic)
4343
(rc, final_mid) = mqttc.publish(msg.topic, None, 1, True)
4444

@@ -96,7 +96,7 @@ def main(argv):
9696
elif opt in ("-v", "--verbose"):
9797
verbose = True
9898

99-
if topic == None:
99+
if not topic:
100100
print("You must provide a topic to clear.\n")
101101
print_usage()
102102
sys.exit(2)

examples/client_pub_opts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
parser.add_argument('-d', '--disable-clean-session', action='store_true', help="disable 'clean session' (sub + msgs not cleared when client disconnects)")
3333
parser.add_argument('-p', '--password', required=False, default=None)
3434
parser.add_argument('-P', '--port', required=False, type=int, default=None, help='Defaults to 8883 for TLS or 1883 for non-TLS')
35-
parser.add_argument('-N', '--nummsgs', required=False, type=int, default=1, help='send this many messages before disconnecting')
36-
parser.add_argument('-S', '--delay', required=False, type=float, default=1, help='number of seconds to sleep between msgs')
35+
parser.add_argument('-N', '--nummsgs', required=False, type=int, default=1, help='send this many messages before disconnecting')
36+
parser.add_argument('-S', '--delay', required=False, type=float, default=1, help='number of seconds to sleep between msgs')
3737
parser.add_argument('-k', '--keepalive', required=False, type=int, default=60)
3838
parser.add_argument('-s', '--use-tls', action='store_true')
3939
parser.add_argument('--insecure', action='store_true')
@@ -68,7 +68,7 @@ def on_log(mqttc, obj, level, string):
6868
if args.cacerts:
6969
usetls = True
7070

71-
port = args.port
71+
port = args.port
7272
if port is None:
7373
if usetls:
7474
port = 8883
@@ -94,7 +94,7 @@ def on_log(mqttc, obj, level, string):
9494
cert_required = ssl.CERT_REQUIRED
9595
else:
9696
cert_required = ssl.CERT_NONE
97-
97+
9898
mqttc.tls_set(ca_certs=args.cacerts, certfile=None, keyfile=None, cert_reqs=cert_required, tls_version=tlsVersion)
9999

100100
if args.insecure:
@@ -125,4 +125,4 @@ def on_log(mqttc, obj, level, string):
125125
time.sleep(args.delay)
126126

127127
mqttc.disconnect()
128-
128+

examples/client_rpc_math.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
# Copyright (c) 2020 Frank Pagliughi <fpagliughi@mindspring.com>
5-
# All rights reserved.
6-
#
7-
# This program and the accompanying materials are made available
5+
# All rights reserved.
6+
#
7+
# This program and the accompanying materials are made available
88
# under the terms of the Eclipse Distribution License v1.0
99
# which accompanies this distribution.
1010
#
@@ -96,7 +96,7 @@ def on_message(mqttc, userdata, msg):
9696
args.append(float(s))
9797

9898
# Send the request
99-
topic = "requests/math/" + func
99+
topic = "requests/math/" + func
100100
payload = json.dumps(args)
101101
mqttc.publish(topic, payload, qos=1, properties=props)
102102

examples/client_sub_opts.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def on_log(mqttc, obj, level, string):
6565
if args.cacerts:
6666
usetls = True
6767

68-
port = args.port
68+
port = args.port
6969
if port is None:
7070
if usetls:
7171
port = 8883
@@ -91,7 +91,7 @@ def on_log(mqttc, obj, level, string):
9191
cert_required = ssl.CERT_REQUIRED
9292
else:
9393
cert_required = ssl.CERT_NONE
94-
94+
9595
mqttc.tls_set(ca_certs=args.cacerts, certfile=None, keyfile=None, cert_reqs=cert_required, tls_version=tlsVersion)
9696

9797
if args.insecure:

examples/server_rpc_math.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
# -*- coding: utf-8 -*-
33

44
# Copyright (c) 2020 Frank Pagliughi <fpagliughi@mindspring.com>
5-
# All rights reserved.
6-
#
7-
# This program and the accompanying materials are made available
5+
# All rights reserved.
6+
#
7+
# This program and the accompanying materials are made available
88
# under the terms of the Eclipse Distribution License v1.0
99
# which accompanies this distribution.
1010
#
@@ -45,7 +45,7 @@ def on_connect(mqttc, userdata, flags, rc, props):
4545
print("Subscribing to math requests")
4646
mqttc.subscribe("requests/math/#")
4747

48-
# Each incoming message should be an RPC request on the
48+
# Each incoming message should be an RPC request on the
4949
# 'requests/math/#' topic.
5050
def on_message(mqttc, userdata, msg):
5151
print(msg.topic + " " + str(msg.payload))
@@ -83,7 +83,7 @@ def on_log(mqttc, obj, level, string):
8383

8484

8585
# Typically with an RPC service, you want to make sure that you're the only
86-
# client answering requests for specific topics. Using a known client ID
86+
# client answering requests for specific topics. Using a known client ID
8787
# might help.
8888
mqttc = mqtt.Client(client_id="paho_rpc_math_srvr", protocol=mqtt.MQTTv5)
8989
mqttc.on_message = on_message

pyproject.toml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,29 @@ testpaths = "tests src"
7474
[tool.ruff]
7575
exclude = ["test/lib/python/*"]
7676
extend-select = [
77-
"S", # Bandit
77+
"B",
7878
"E9",
7979
"F63",
8080
"F7",
8181
"F82",
8282
"I",
83+
"S", # Bandit
84+
"UP",
85+
"W",
8386
]
84-
ignore = [
85-
"E402", # TODO: enable
86-
"E711", # TODO: enable
87-
"E712", # TODO: enable
88-
"E721", # TODO: enable
89-
"S101", # TODO: enable
90-
"S110", # TODO: enable
91-
"S324", # TODO: enable
92-
]
87+
ignore = []
9388
line-length = 167
9489

9590
[tool.ruff.per-file-ignores]
9691
"{test,tests,examples}/**/*.py" = [
92+
"B",
93+
"E402",
94+
"E711",
9795
"E741",
9896
"F401",
9997
"F811",
10098
"F841",
10199
"I",
102100
"S",
103-
]
101+
"UP",
102+
]

0 commit comments

Comments
 (0)