Skip to content

Commit

Permalink
Fix ruff F findings
Browse files Browse the repository at this point in the history
  • Loading branch information
timwoj committed Dec 7, 2024
1 parent 9c64242 commit 9ad0642
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 33 deletions.
10 changes: 0 additions & 10 deletions bindings/python/broker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import collections
import datetime
import ipaddress
import sys
import time
import types

try:
Expand Down Expand Up @@ -308,14 +306,6 @@ def __exit__(self, type, value, traceback):
self._parent = None
self._store = None

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
self._store.reset()
self._parent = None
self._store = None

def name(self):
return self._store.name()

Expand Down
2 changes: 1 addition & 1 deletion ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ exclude = ["auxil",
"tests/btest//store"]

[lint]
select = ["C4", "I", "ISC", "UP"]
select = ["C4", "F", "I", "ISC", "UP"]
1 change: 1 addition & 0 deletions tests/btest/scripts/wire_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import struct
import sys
import time
import traceback
import uuid
from collections import namedtuple
from enum import IntEnum
Expand Down
6 changes: 2 additions & 4 deletions tests/python/communication.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import ipaddress
import multiprocessing
import sys
import time
import unittest

Expand Down Expand Up @@ -184,8 +182,8 @@ def test_status_subscriber_error(self):
def test_idle_endpoint(self):
with (
broker.Endpoint() as ep1,
ep1.make_status_subscriber() as es1,
ep1.make_subscriber("/test") as s1,
ep1.make_status_subscriber() as es1, # noqa: F841
ep1.make_subscriber("/test") as s1, # noqa: F841
):
pass

Expand Down
3 changes: 1 addition & 2 deletions tests/python/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import datetime
import ipaddress
import math
import sys
import time
import types
import unittest
Expand Down Expand Up @@ -117,7 +116,7 @@ def test_count(self):
)

def test_count_overflow(self):
with self.assertRaises(Exception) as context:
with self.assertRaises(Exception) as context: # noqa: F841
# I've seen this raise either OverflowError or SystemError
# depending on Python version is seems.
self.check_to_broker(broker.Count(-1), "-1", broker.Data.Type.Count)
Expand Down
3 changes: 0 additions & 3 deletions tests/python/forwarding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import multiprocessing
import sys
import time
import unittest

import broker
Expand Down
3 changes: 0 additions & 3 deletions tests/python/ssl-tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import multiprocessing
import os.path
import sys
import time
import unittest

import broker
Expand Down
14 changes: 7 additions & 7 deletions tests/python/store.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import sys
import time
import unittest
from inspect import currentframe, getframeinfo

import broker

Expand All @@ -12,11 +10,11 @@ def create_stores(self):
ep2 = broker.Endpoint()

with (
ep0.make_subscriber("/test") as s0,
ep0.make_subscriber("/test") as s0, # noqa: F841
ep1.make_subscriber("/test") as s1,
ep1.make_status_subscriber() as es1,
ep1.make_status_subscriber() as es1, # noqa: F841
ep2.make_subscriber("/test") as s2,
ep2.make_status_subscriber() as es2,
ep2.make_status_subscriber() as es2, # noqa: F841
):
p = ep0.listen("127.0.0.1", 0)
ep1.peer("127.0.0.1", p)
Expand Down Expand Up @@ -192,8 +190,10 @@ def test_from_one_clone(self):

v1 = "A"
v2 = {"A", "B", "C"}
v3 = {1: "A", 2: "B", 3: "C"}
v4 = ("A", "B", "C")

# TODO: These are untested, should they be?
# v3 = {1: "A", 2: "B", 3: "C"}
# v4 = ("A", "B", "C")

c1.put("a", v1)
c1.put("b", v2)
Expand Down
6 changes: 4 additions & 2 deletions tests/python/zeek-unsafe-types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import unittest

import broker
from zeek_common import run_zeek, run_zeek_path
from zeek_common import run_zeek

ZeekHello = """
redef Broker::default_connect_retry=1secs;
Expand Down Expand Up @@ -79,7 +79,9 @@ def test_safe(self):
# broker.zeek.SafeEvent uses broker.ImmutableData, so can access
# the arguments safely:
ev = broker.zeek.SafeEvent(msg)
args = ev.args()

# TODO: should this test inspect the args somehow?
args = ev.args() # noqa: F841


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion tests/python/zeek.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime

import broker
from zeek_common import run_zeek, run_zeek_path
from zeek_common import run_zeek

ZeekPing = """
redef Broker::default_connect_retry=1secs;
Expand Down

0 comments on commit 9ad0642

Please sign in to comment.