Skip to content

Commit

Permalink
Fixed code issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Oct 14, 2024
1 parent f3bc031 commit fca2cd5
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 24 deletions.
3 changes: 2 additions & 1 deletion pysnmp/carrier/asyncio/dgram/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down
3 changes: 2 additions & 1 deletion pysnmp/carrier/asyncio/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down
3 changes: 2 additions & 1 deletion pysnmp/entity/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down
2 changes: 2 additions & 0 deletions pysnmp/entity/rfc3413/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down
9 changes: 1 addition & 8 deletions pysnmp/hlapi/v1arch/asyncio/cmdgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,13 +26,6 @@
"walk_cmd",
"bulk_walk_cmd",
"is_end_of_mib",
"getCmd",
"nextCmd",
"setCmd",
"bulkCmd",
"walkCmd",
"bulkWalkCmd",
"isEndOfMib",
]

VB_PROCESSOR = varbinds.CommandGeneratorVarBinds()
Expand Down
2 changes: 1 addition & 1 deletion pysnmp/hlapi/v1arch/asyncio/ntforg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion pysnmp/hlapi/v1arch/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# Copyright (c) 2005-2020, Ilya Etingof <[email protected]>
# 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
Expand Down
1 change: 1 addition & 0 deletions pysnmp/hlapi/v3arch/asyncio/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
9 changes: 1 addition & 8 deletions pysnmp/hlapi/v3arch/asyncio/cmdgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -58,13 +58,6 @@
"walk_cmd",
"bulk_walk_cmd",
"is_end_of_mib",
"getCmd",
"nextCmd",
"setCmd",
"bulkCmd",
"walkCmd",
"bulkWalkCmd",
"isEndOfMib",
]

VB_PROCESSOR = varbinds.CommandGeneratorVarBinds()
Expand Down
2 changes: 1 addition & 1 deletion pysnmp/hlapi/v3arch/asyncio/ntforg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions pysnmp/proto/rfc1902.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.",
Expand Down
3 changes: 2 additions & 1 deletion pysnmp/proto/rfc3412.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.",
Expand Down
2 changes: 1 addition & 1 deletion pysnmp/smi/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pysnmp/smi/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions pysnmp/smi/instrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions pysnmp/smi/rfc1902.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 1 addition & 0 deletions pysnmp/smi/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fca2cd5

Please sign in to comment.