From 9e9728d2622b628db63297b3a24704c10a63c3ea Mon Sep 17 00:00:00 2001
From: Hannes Feldt <feldt@astron.nl>
Date: Wed, 15 May 2024 14:54:27 +0200
Subject: [PATCH] fix linting

---
 lofar_station_client/file_access/_utils.py           |  5 ++---
 lofar_station_client/file_access/hdf/_hdf5_utils.py  |  6 +++---
 lofar_station_client/file_access/hdf/_hdf_readers.py |  7 +++----
 lofar_station_client/file_access/hdf/_hdf_writers.py |  5 ++---
 lofar_station_client/statistics/receivers/_zmq.py    | 12 ++++++------
 5 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/lofar_station_client/file_access/_utils.py b/lofar_station_client/file_access/_utils.py
index bb8eadd..6a34901 100644
--- a/lofar_station_client/file_access/_utils.py
+++ b/lofar_station_client/file_access/_utils.py
@@ -1,14 +1,13 @@
-#  Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
+#  Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
 #  SPDX-License-Identifier: Apache-2.0
 
 """
 General utils
 """
-from typing import Optional, Type, get_type_hints
+from typing import Optional, Type, get_type_hints, get_args, get_origin
 
 from numpy import ndarray
 
-from ._compat_utils import get_args, get_origin
 from ._monitoring import MonitoredWrapper
 
 
diff --git a/lofar_station_client/file_access/hdf/_hdf5_utils.py b/lofar_station_client/file_access/hdf/_hdf5_utils.py
index 7dbbfc5..e2ce627 100644
--- a/lofar_station_client/file_access/hdf/_hdf5_utils.py
+++ b/lofar_station_client/file_access/hdf/_hdf5_utils.py
@@ -1,4 +1,4 @@
-#  Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
+#  Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
 #  SPDX-License-Identifier: Apache-2.0
 
 """
@@ -6,11 +6,11 @@ Utils to handle transformation of HDF5 specific classes to pythonic objects
 """
 import inspect
 from collections.abc import MutableMapping
-from typing import Type, TypeVar
+from typing import Type, TypeVar, get_origin
 
 from numpy import ndarray
 
-from .._compat_utils import get_origin, get_annotations
+from .._compat_utils import get_annotations
 
 T = TypeVar("T")
 
diff --git a/lofar_station_client/file_access/hdf/_hdf_readers.py b/lofar_station_client/file_access/hdf/_hdf_readers.py
index f63ee80..bdbbe25 100644
--- a/lofar_station_client/file_access/hdf/_hdf_readers.py
+++ b/lofar_station_client/file_access/hdf/_hdf_readers.py
@@ -1,4 +1,4 @@
-#  Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
+#  Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
 #  SPDX-License-Identifier: Apache-2.0
 
 """
@@ -7,7 +7,7 @@ Contains classes to handle file reading
 import inspect
 import weakref
 from inspect import getattr_static
-from typing import TypeVar, Type, List, Dict
+from typing import TypeVar, Type, List, Dict, get_origin
 
 import h5py
 from numpy import ndarray, zeros
@@ -17,7 +17,6 @@ from ._hdf5_utils import (
     _assert_is_dataset,
 )
 from .._attribute_def import AttributeDef
-from .._compat_utils import get_origin
 from .._lazy_dict import lazy_dict
 from .._member_def import MemberDef
 from .._readers import FileReader, DataReader
@@ -169,7 +168,7 @@ class HdfDataReader(DataReader):
         reader = cls.detect_reader(target_type, data_reader)
         result = lazy_dict(dict_type, lambda k: reader(value[k]))
         for k in value.keys():
-            result[k] = lambda k=k: reader(value[k])
+            result[k] = lambda n=k: reader(value[n])
         if dict_type is not dict:
             setattr(result, "_data_reader", cls(data_reader.file_reader, value))
         return result
diff --git a/lofar_station_client/file_access/hdf/_hdf_writers.py b/lofar_station_client/file_access/hdf/_hdf_writers.py
index c745e3b..49c871c 100644
--- a/lofar_station_client/file_access/hdf/_hdf_writers.py
+++ b/lofar_station_client/file_access/hdf/_hdf_writers.py
@@ -1,11 +1,11 @@
-#  Copyright (C) 2023 ASTRON (Netherlands Institute for Radio Astronomy)
+#  Copyright (C) 2024 ASTRON (Netherlands Institute for Radio Astronomy)
 #  SPDX-License-Identifier: Apache-2.0
 
 """
 Contains classes to handle file writing
 """
 from inspect import getattr_static
-from typing import TypeVar, Type, Dict
+from typing import TypeVar, Type, Dict, get_origin
 
 import h5py
 from numpy import ndarray
@@ -17,7 +17,6 @@ from ._hdf5_utils import (
     _assert_is_dataset,
 )
 from ._hdf_readers import HdfFileReader, HdfDataReader
-from .._compat_utils import get_origin
 from .._lazy_dict import LazyDict
 from .._utils import _wrap, _extract_base_type
 from .._writers import FileWriter, DataWriter
diff --git a/lofar_station_client/statistics/receivers/_zmq.py b/lofar_station_client/statistics/receivers/_zmq.py
index 839519c..f078fec 100644
--- a/lofar_station_client/statistics/receivers/_zmq.py
+++ b/lofar_station_client/statistics/receivers/_zmq.py
@@ -16,15 +16,13 @@ class ZeroMQReceiver:
     """ZeroMQ Receiver"""
 
     def __init__(self, uri: str):
-
         o = urlsplit(uri)
-        self._ctx: zmq.Context = zmq.Context.instance()
-        self._subscriber: zmq.Socket = self._ctx.socket(zmq.SUB)
-        self._topic: bytes = o.path.strip("/").encode()
 
-        self._subscriber.connect(f"{o.scheme}://{o.netloc}")
-        self._subscriber.setsockopt(zmq.SUBSCRIBE, self._topic)
+        self._topic: bytes = o.path.strip("/").encode()
+        self._uri = f"{o.scheme}://{o.netloc}"
         self._content_type = "application/octet-stream"
+        self._ctx: zmq.Context = zmq.Context.instance()
+        self._subscriber: zmq.Socket = self._ctx.socket(zmq.SUB)
 
         qs = parse_qs(o.query)
         if "content-type" in qs:
@@ -34,6 +32,8 @@ class ZeroMQReceiver:
 
     def __iter__(self):
         """Iterates over all packets in the stream."""
+        self._subscriber.connect(self._uri)
+        self._subscriber.setsockopt(zmq.SUBSCRIBE, self._topic)
         return self
 
     def __next__(self) -> Union[str, dict, bytes]:
-- 
GitLab