Skip to content

Commit

Permalink
Fixed the positional arguments enforcement
Browse files Browse the repository at this point in the history
  • Loading branch information
ccie18643 committed Sep 3, 2024
1 parent 278766f commit ebb8fbc
Show file tree
Hide file tree
Showing 20 changed files with 209 additions and 412 deletions.
4 changes: 2 additions & 2 deletions pytcp/lib/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class PacketIntegrityError(PacketValidationError):
Exception raised when integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[INTEGRITY ERROR]" + message)


Expand All @@ -62,5 +62,5 @@ class PacketSanityError(PacketValidationError):
Exception raised when sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[SANITY ERROR]" + message)
22 changes: 11 additions & 11 deletions pytcp/lib/net_addr/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Ip4AddressFormatError(IpAddressFormatError):
Exception raised when IPv4 address format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv4 address format is invalid: {message!r}")


Expand All @@ -88,7 +88,7 @@ class Ip4MaskFormatError(IpMaskFormatError):
Exception raised when IPv4 mask format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv4 mask format is invalid: {message!r}")


Expand All @@ -97,7 +97,7 @@ class Ip4NetworkFormatError(IpNetworkFormatError):
Exception raised when IPv4 network format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv4 network format is invalid: {message!r}")


Expand All @@ -106,7 +106,7 @@ class Ip4HostFormatError(IpHostFormatError):
Exception raised when IPv4 host format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv4 host format is invalid: {message!r}")


Expand All @@ -115,7 +115,7 @@ class Ip4HostGatewayError(IpHostGatewayError):
Exception raised when IPv4 host gateway is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv4 host gateway is invalid: {message!r}")


Expand All @@ -124,7 +124,7 @@ class Ip6AddressFormatError(IpAddressFormatError):
Exception raised when IPv6 address format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv6 address format is invalid: {message!r}")


Expand All @@ -133,7 +133,7 @@ class Ip6MaskFormatError(IpMaskFormatError):
Exception raised when IPv6 mask format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv6 mask format is invalid: {message!r}")


Expand All @@ -142,7 +142,7 @@ class Ip6NetworkFormatError(IpNetworkFormatError):
Exception raised when IPv6 network format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv6 network format is invalid: {message!r}")


Expand All @@ -151,7 +151,7 @@ class Ip6HostFormatError(IpHostFormatError):
Exception raised when IPv6 host format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv6 host format is invalid: {message!r}")


Expand All @@ -160,7 +160,7 @@ class Ip6HostGatewayError(IpHostGatewayError):
Exception raised when IPv6 host gateway is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The IPv6 host gateway is invalid: {message!r}")


Expand All @@ -169,5 +169,5 @@ class MacAddressFormatError(Exception):
Exception raised when MAC address format is invalid.
"""

def __init__(self, /, message: Any):
def __init__(self, message: Any, /):
super().__init__(f"The MAC address format is invalid: {message!r}")
2 changes: 1 addition & 1 deletion pytcp/lib/net_addr/ip4_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class Ip4Address(IpAddress):

def __init__(
self,
/,
address: (
Ip4Address | str | bytes | bytearray | memoryview | int | None
) = None,
/,
) -> None:
"""
Create a new IPv4 address object.
Expand Down
2 changes: 1 addition & 1 deletion pytcp/lib/net_addr/ip4_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ class Ip4Mask(IpMask):

def __init__(
self,
/,
mask: (
Ip4Mask | str | bytes | bytearray | memoryview | int | None
) = None,
/,
) -> None:
"""
Create a new IPv4 mask object.
Expand Down
2 changes: 1 addition & 1 deletion pytcp/lib/net_addr/ip6_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ class Ip6Address(IpAddress):

def __init__(
self,
/,
address: (
Ip6Address | str | bytes | bytearray | memoryview | int | None
) = None,
/,
) -> None:
"""
Create a new IPv6 address object.
Expand Down
2 changes: 1 addition & 1 deletion pytcp/lib/net_addr/mac_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ class MacAddress(Address):

def __init__(
self,
/,
address: (
MacAddress | str | bytes | bytearray | memoryview | int | None
) = None,
/,
) -> None:
"""
Create a new MAC address object.
Expand Down
4 changes: 2 additions & 2 deletions pytcp/protocols/arp/arp__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ArpIntegrityError(PacketIntegrityError):
Exception raised when ARP packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[ARP] " + message)


Expand All @@ -52,5 +52,5 @@ class ArpSanityError(PacketSanityError):
Exception raised when ARP packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[ARP] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/ethernet/ethernet__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class EthernetIntegrityError(PacketIntegrityError):
Exception raised when Ethernet packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[Ethernet] " + message)


Expand All @@ -52,5 +52,5 @@ class EthernetSanityError(PacketSanityError):
Exception raised when Ethernet packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[Ethernet] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/ethernet_802_3/ethernet_802_3__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Ethernet8023IntegrityError(PacketIntegrityError):
Exception raised when Ethernet 802.3 packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[Ethernet 802.3] " + message)


Expand All @@ -52,5 +52,5 @@ class Ethernet8023SanityError(PacketSanityError):
Exception raised when Ethernet 802.3 packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[Ethernet 802.3] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/icmp4/icmp4__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Icmp4IntegrityError(PacketIntegrityError):
The ICMPv4 packet integrity check failure.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[ICMPv4] " + message)


Expand All @@ -52,5 +52,5 @@ class Icmp4SanityError(PacketSanityError):
The ICMPv4 packet sanity check failure.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[ICMPv4] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/icmp6/icmp6__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Icmp6IntegrityError(PacketIntegrityError):
Exception raised when ICMPv6 packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[ICMPv6] " + message)


Expand All @@ -52,5 +52,5 @@ class Icmp6SanityError(PacketSanityError):
Exception raised when ICMPv6 packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[ICMPv6] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/ip4/ip4__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Ip4IntegrityError(PacketIntegrityError):
Exception raised when IPv4 packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[IPv4] " + message)


Expand All @@ -52,5 +52,5 @@ class Ip4SanityError(PacketSanityError):
Exception raised when IPv4 packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[IPv4] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/ip6/ip6__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Ip6IntegrityError(PacketIntegrityError):
Exception raised when IPv6 packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[IPv6] " + message)


Expand All @@ -52,5 +52,5 @@ class Ip6SanityError(PacketSanityError):
Exception raised when IPv6 packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[IPv6] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/ip6_ext_frag/ip6_ext_frag__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Ip6ExtFragIntegrityError(PacketIntegrityError):
Exception raised when IPv6 Ext Frag packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[IPv6 Ext Frag] " + message)


Expand All @@ -52,5 +52,5 @@ class Ip6ExtFragSanityError(PacketSanityError):
Exception raised when IPv6 Ext Frag packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[IPv6 Ext Frag] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/tcp/tcp__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TcpIntegrityError(PacketIntegrityError):
Exception raised when TCP packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[TCP] " + message)


Expand All @@ -52,5 +52,5 @@ class TcpSanityError(PacketSanityError):
Exception raised when TCP packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[TCP] " + message)
4 changes: 2 additions & 2 deletions pytcp/protocols/udp/udp__errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UdpIntegrityError(PacketIntegrityError):
Exception raised when UDP packet integrity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[UDP] " + message)


Expand All @@ -52,5 +52,5 @@ class UdpSanityError(PacketSanityError):
Exception raised when UDP packet sanity check fails.
"""

def __init__(self, /, message: str):
def __init__(self, message: str, /):
super().__init__("[UDP] " + message)
Loading

0 comments on commit ebb8fbc

Please sign in to comment.