diff --git a/pysnmp/carrier/asyncio/dgram/base.py b/pysnmp/carrier/asyncio/dgram/base.py index 854def5a..6eb546b3 100644 --- a/pysnmp/carrier/asyncio/dgram/base.py +++ b/pysnmp/carrier/asyncio/dgram/base.py @@ -73,8 +73,8 @@ import asyncio import sys import traceback -from socket import socket import warnings +from socket import socket from pysnmp import debug from pysnmp.carrier import error @@ -227,6 +227,7 @@ def normalize_address( } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/carrier/asyncio/dispatch.py b/pysnmp/carrier/asyncio/dispatch.py index d5b63887..504991bf 100644 --- a/pysnmp/carrier/asyncio/dispatch.py +++ b/pysnmp/carrier/asyncio/dispatch.py @@ -36,9 +36,9 @@ import asyncio import sys import traceback +import warnings from time import time from typing import Tuple -import warnings from pysnmp.carrier.base import AbstractTransport, AbstractTransportDispatcher from pysnmp.error import PySnmpError @@ -114,6 +114,7 @@ def unregister_transport(self, tDomain: Tuple[int, ...]): } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/entity/engine.py b/pysnmp/entity/engine.py index 0254d696..cfae851c 100644 --- a/pysnmp/entity/engine.py +++ b/pysnmp/entity/engine.py @@ -8,8 +8,8 @@ import shutil import sys import tempfile -from typing import Any, Dict import warnings +from typing import Any, Dict from pyasn1.type import univ @@ -291,6 +291,7 @@ def delete_user_context(self, arg): } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/entity/rfc3413/context.py b/pysnmp/entity/rfc3413/context.py index cdca5a22..3bee4e27 100644 --- a/pysnmp/entity/rfc3413/context.py +++ b/pysnmp/entity/rfc3413/context.py @@ -5,6 +5,7 @@ # License: https://www.pysnmp.com/pysnmp/license.html # import warnings + from pyasn1.type import univ from pysnmp import debug, error from pysnmp.entity.engine import SnmpEngine @@ -78,6 +79,7 @@ def get_mib_instrum(self, contextName: bytes = b"") -> MibInstrumController: } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/hlapi/v1arch/asyncio/cmdgen.py b/pysnmp/hlapi/v1arch/asyncio/cmdgen.py index 8968b127..1cdd937c 100644 --- a/pysnmp/hlapi/v1arch/asyncio/cmdgen.py +++ b/pysnmp/hlapi/v1arch/asyncio/cmdgen.py @@ -5,8 +5,8 @@ # License: https://www.pysnmp.com/pysnmp/license.html # import asyncio -from typing import AsyncGenerator import warnings +from typing import AsyncGenerator from pysnmp.hlapi import varbinds from pysnmp.hlapi.transport import AbstractTransportTarget @@ -26,13 +26,6 @@ "walk_cmd", "bulk_walk_cmd", "is_end_of_mib", - "getCmd", - "nextCmd", - "setCmd", - "bulkCmd", - "walkCmd", - "bulkWalkCmd", - "isEndOfMib", ] VB_PROCESSOR = varbinds.CommandGeneratorVarBinds() diff --git a/pysnmp/hlapi/v1arch/asyncio/ntforg.py b/pysnmp/hlapi/v1arch/asyncio/ntforg.py index 7d8794ce..bf290ced 100644 --- a/pysnmp/hlapi/v1arch/asyncio/ntforg.py +++ b/pysnmp/hlapi/v1arch/asyncio/ntforg.py @@ -17,7 +17,7 @@ from pysnmp.proto.rfc1902 import Integer32 from pysnmp.smi.rfc1902 import ObjectType -__all__ = ["send_notification", "sendNotification"] +__all__ = ["send_notification"] VB_PROCESSOR = NotificationOriginatorVarBinds() diff --git a/pysnmp/hlapi/v1arch/dispatch.py b/pysnmp/hlapi/v1arch/dispatch.py index 3eda7437..8a484f98 100644 --- a/pysnmp/hlapi/v1arch/dispatch.py +++ b/pysnmp/hlapi/v1arch/dispatch.py @@ -4,8 +4,8 @@ # Copyright (c) 2005-2020, Ilya Etingof # License: https://www.pysnmp.com/pysnmp/license.html # -from time import time import warnings +from time import time from pyasn1.codec.ber import decoder, encoder from pysnmp import debug diff --git a/pysnmp/hlapi/v3arch/asyncio/auth.py b/pysnmp/hlapi/v3arch/asyncio/auth.py index 80a8f47d..baa9cd31 100644 --- a/pysnmp/hlapi/v3arch/asyncio/auth.py +++ b/pysnmp/hlapi/v3arch/asyncio/auth.py @@ -485,6 +485,7 @@ def clone( } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/hlapi/v3arch/asyncio/cmdgen.py b/pysnmp/hlapi/v3arch/asyncio/cmdgen.py index c63634f6..daefbfa3 100644 --- a/pysnmp/hlapi/v3arch/asyncio/cmdgen.py +++ b/pysnmp/hlapi/v3arch/asyncio/cmdgen.py @@ -34,8 +34,8 @@ # THE POSSIBILITY OF SUCH DAMAGE. # import asyncio -from typing import AsyncGenerator import warnings +from typing import AsyncGenerator from pysnmp.entity.engine import SnmpEngine from pysnmp.entity.rfc3413 import cmdgen @@ -58,13 +58,6 @@ "walk_cmd", "bulk_walk_cmd", "is_end_of_mib", - "getCmd", - "nextCmd", - "setCmd", - "bulkCmd", - "walkCmd", - "bulkWalkCmd", - "isEndOfMib", ] VB_PROCESSOR = varbinds.CommandGeneratorVarBinds() diff --git a/pysnmp/hlapi/v3arch/asyncio/ntforg.py b/pysnmp/hlapi/v3arch/asyncio/ntforg.py index b04a5b0e..e302295a 100644 --- a/pysnmp/hlapi/v3arch/asyncio/ntforg.py +++ b/pysnmp/hlapi/v3arch/asyncio/ntforg.py @@ -21,7 +21,7 @@ from pysnmp.hlapi.varbinds import NotificationOriginatorVarBinds from pysnmp.smi.rfc1902 import NotificationType -__all__ = ["send_notification", "sendNotification"] +__all__ = ["send_notification"] VB_PROCESSOR = NotificationOriginatorVarBinds() LCD = NotificationOriginatorLcdConfigurator() diff --git a/pysnmp/proto/rfc1902.py b/pysnmp/proto/rfc1902.py index 4880ae3c..34f00b7c 100644 --- a/pysnmp/proto/rfc1902.py +++ b/pysnmp/proto/rfc1902.py @@ -5,6 +5,7 @@ # License: https://www.pysnmp.com/pysnmp/license.html # import warnings + from pyasn1.type import constraint, namedtype, namedval, tag, univ from pysnmp.proto import error, rfc1155 @@ -280,6 +281,7 @@ class X(cls): } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/proto/rfc3412.py b/pysnmp/proto/rfc3412.py index d51c28bd..5cec72f3 100644 --- a/pysnmp/proto/rfc3412.py +++ b/pysnmp/proto/rfc3412.py @@ -5,8 +5,8 @@ # License: https://www.pysnmp.com/pysnmp/license.html # import sys -from typing import TYPE_CHECKING import warnings +from typing import TYPE_CHECKING from pyasn1.error import PyAsn1Error @@ -727,6 +727,7 @@ def receive_timer_tick(self, snmpEngine: "SnmpEngine", timeNow): } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/smi/builder.py b/pysnmp/smi/builder.py index 50ffd7ee..13621f37 100644 --- a/pysnmp/smi/builder.py +++ b/pysnmp/smi/builder.py @@ -10,10 +10,10 @@ import sys import time import traceback +import warnings from errno import ENOENT from importlib.machinery import BYTECODE_SUFFIXES, SOURCE_SUFFIXES from importlib.util import MAGIC_NUMBER as PY_MAGIC_NUMBER -import warnings from pysnmp import debug, version as pysnmp_version from pysnmp.smi import error diff --git a/pysnmp/smi/indices.py b/pysnmp/smi/indices.py index 9a68e95b..abeb255d 100644 --- a/pysnmp/smi/indices.py +++ b/pysnmp/smi/indices.py @@ -113,6 +113,7 @@ def get_keys_lengths(self): } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/smi/instrum.py b/pysnmp/smi/instrum.py index 78ba4f81..c5fe98db 100644 --- a/pysnmp/smi/instrum.py +++ b/pysnmp/smi/instrum.py @@ -297,6 +297,7 @@ def write_variables(self, *varBinds, **context): } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/smi/rfc1902.py b/pysnmp/smi/rfc1902.py index 23ea6a7d..aca5c10a 100644 --- a/pysnmp/smi/rfc1902.py +++ b/pysnmp/smi/rfc1902.py @@ -1466,6 +1466,7 @@ def to_varbinds(self) -> "tuple[ObjectType, ...]": } def __getattr__(self, attr: str): + """Handle deprecated attributes.""" if new_attr := self.deprecated_attributes.get(attr): warnings.warn( f"{attr} is deprecated. Please use {new_attr} instead.", diff --git a/pysnmp/smi/view.py b/pysnmp/smi/view.py index 98a07425..8412e111 100644 --- a/pysnmp/smi/view.py +++ b/pysnmp/smi/view.py @@ -5,6 +5,7 @@ # License: https://www.pysnmp.com/pysnmp/license.html # import warnings + from pysnmp import debug from pysnmp.smi import error from pysnmp.smi.builder import MibBuilder