Skip to content

Commit

Permalink
Don't define TrapObserver as Protocol
Browse files Browse the repository at this point in the history
The changed implementation relies on inheritance of `__init__`, making
this no longer a clean "Protocol", but a base class.  While this is
apparently supported in Python 3.11, Python versions earlier than 3.11
would override the inherited `__init__` method, thereby breaking this
implementation.

See python/cpython#88970 for details
  • Loading branch information
lunkwill42 committed May 29, 2024
1 parent d7cec4a commit 587c522
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/zino/trapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from dataclasses import dataclass, field
from ipaddress import ip_address
from typing import Any, List, NamedTuple, Optional, Protocol, Set
from typing import Any, List, NamedTuple, Optional, Set

from pysnmp.carrier.asyncio.dgram import udp
from pysnmp.entity import config
Expand Down Expand Up @@ -54,7 +54,7 @@ def __str__(self):
return f"<Trap from {self.agent.device.name}: {variables}>"


class TrapObserver(Protocol):
class TrapObserver:
"""Defines a valid protocol for SNMP trap observers.
A trap observer that directly subclasses this protocol can expect to be automatically registered by Zino as an
Expand Down

0 comments on commit 587c522

Please sign in to comment.