From 82891aa9867cea0a212f80aacd81d1d30852698f Mon Sep 17 00:00:00 2001 From: Thomas Mangin Date: Thu, 6 Jun 2024 16:57:34 +0100 Subject: [PATCH] run black --- pyproject.toml | 3 +-- src/exabgp/application/tojson.py | 2 +- .../message/update/attribute/attributes.py | 22 ++++++++++--------- .../attribute/community/extended/traffic.py | 8 ++++--- src/exabgp/configuration/neighbor/parser.py | 3 ++- src/exabgp/reactor/api/processes.py | 2 +- src/exabgp/reactor/network/tcp.py | 2 +- src/exabgp/reactor/peer.py | 4 +--- src/exabgp/vendoring/objgraph.py | 1 + 9 files changed, 25 insertions(+), 22 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9999fec87..707d15a83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,9 +66,8 @@ exabgp-cli = 'exabgp.application.cli:main' exabgp-healthcheck = 'exabgp.application.healthcheck:main' [tool.black] -optional = true line-length = 120 -target-version = ['py36', 'py37', 'py38'] +target-version = ['py36', 'py37', 'py38', 'py39', 'py310', 'py311', 'py312', 'py313'] skip_string_normalization = '1' include = '\.pyi?$' exclude = ''' diff --git a/src/exabgp/application/tojson.py b/src/exabgp/application/tojson.py index 0731fed83..e86261055 100644 --- a/src/exabgp/application/tojson.py +++ b/src/exabgp/application/tojson.py @@ -60,7 +60,7 @@ def process(self): run, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - preexec_fn=preexec_helper + preexec_fn=preexec_helper, # This flags exists for python 2.7.3 in the documentation but on on my MAC # creationflags=subprocess.CREATE_NEW_PROCESS_GROUP ) diff --git a/src/exabgp/bgp/message/update/attribute/attributes.py b/src/exabgp/bgp/message/update/attribute/attributes.py index 666f4ffaf..064d9a26f 100644 --- a/src/exabgp/bgp/message/update/attribute/attributes.py +++ b/src/exabgp/bgp/message/update/attribute/attributes.py @@ -229,16 +229,18 @@ def pack(self, negotiated, with_default=True): default = { Attribute.CODE.ORIGIN: lambda left, right: Origin(Origin.IGP), - Attribute.CODE.AS_PATH: lambda left, right: ASPath([]) - if left == right - else ASPath( - [ - SEQUENCE( - [ - local_asn, - ] - ), - ], + Attribute.CODE.AS_PATH: lambda left, right: ( + ASPath([]) + if left == right + else ASPath( + [ + SEQUENCE( + [ + local_asn, + ] + ), + ], + ) ), Attribute.CODE.LOCAL_PREF: lambda left, right: LocalPreference(100) if left == right else NOTHING, } diff --git a/src/exabgp/bgp/message/update/attribute/community/extended/traffic.py b/src/exabgp/bgp/message/update/attribute/community/extended/traffic.py index 8014b1101..d9ae35aa1 100644 --- a/src/exabgp/bgp/message/update/attribute/community/extended/traffic.py +++ b/src/exabgp/bgp/message/update/attribute/community/extended/traffic.py @@ -250,9 +250,11 @@ def __init__(self, ip, asn, community=None): self.asn = asn ExtendedCommunityIPv6.__init__( self, - community - if community is not None - else pack("!BB16sH", 0x00, 0x02, socket.inet_pton(socket.AF_INET6, ip), asn), + ( + community + if community is not None + else pack("!BB16sH", 0x00, 0x02, socket.inet_pton(socket.AF_INET6, ip), asn) + ), ) def __str__(self): diff --git a/src/exabgp/configuration/neighbor/parser.py b/src/exabgp/configuration/neighbor/parser.py index e63f7cbcb..2dd4a03e0 100644 --- a/src/exabgp/configuration/neighbor/parser.py +++ b/src/exabgp/configuration/neighbor/parser.py @@ -101,6 +101,7 @@ def local_address(tokeniser): except (IndexError, ValueError, socket.error): raise ValueError('"%s" is an invalid IP address' % value) + def source_interface(tokeniser): try: return string(tokeniser) @@ -181,4 +182,4 @@ def rate_limit(tokeniser): raise ValueError('"%s" is an invalid rate-limit' % value) if rate <= 0: raise ValueError('rate must be zero or at 1 (per second)') - return rate \ No newline at end of file + return rate diff --git a/src/exabgp/reactor/api/processes.py b/src/exabgp/reactor/api/processes.py index 10e875655..1e6479c7e 100644 --- a/src/exabgp/reactor/api/processes.py +++ b/src/exabgp/reactor/api/processes.py @@ -153,7 +153,7 @@ def _start(self, process): run, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - preexec_fn=preexec_helper + preexec_fn=preexec_helper, # This flags exists for python 2.7.3 in the documentation but on on my MAC # creationflags=subprocess.CREATE_NEW_PROCESS_GROUP ) diff --git a/src/exabgp/reactor/network/tcp.py b/src/exabgp/reactor/network/tcp.py index 22d991f90..4f9f9481d 100644 --- a/src/exabgp/reactor/network/tcp.py +++ b/src/exabgp/reactor/network/tcp.py @@ -49,7 +49,7 @@ def create(afi, interface=None): if interface is not None: try: - if not hasattr(socket,'SO_BINDTODEVICE') : + if not hasattr(socket, 'SO_BINDTODEVICE'): socket.SO_BINDTODEVICE = 25 io.setsockopt(socket.SOL_SOCKET, socket.SO_BINDTODEVICE, str(interface + '\0').encode("utf-8")) diff --git a/src/exabgp/reactor/peer.py b/src/exabgp/reactor/peer.py index 3d547cd42..7240dd5aa 100644 --- a/src/exabgp/reactor/peer.py +++ b/src/exabgp/reactor/peer.py @@ -277,9 +277,7 @@ def _connect(self): except Stop: # Connection failed if not connected and self.proto: - self._close( - 'connection to %s:%d failed' % (self.neighbor['peer-address'], self.neighbor['connect']) - ) + self._close('connection to %s:%d failed' % (self.neighbor['peer-address'], self.neighbor['connect'])) # A connection arrived before we could establish ! if not connected or self.proto: diff --git a/src/exabgp/vendoring/objgraph.py b/src/exabgp/vendoring/objgraph.py index 8867b10f8..fa93e3739 100644 --- a/src/exabgp/vendoring/objgraph.py +++ b/src/exabgp/vendoring/objgraph.py @@ -7,6 +7,7 @@ Released under the MIT licence. """ + # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation