Skip to content

Commit 6b2560a

Browse files
thomas-manginclaude
andcommitted
style: apply ruff formatting to 49 files
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4023856 commit 6b2560a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1203
-981
lines changed

qa/self/big/api-internet.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def main():
2727
# initial table dump
2828
for k, v in ip.iteritems():
2929
count += 1
30-
write('announce route {} next-hop {} med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ]'.format(k, v))
30+
write(
31+
'announce route {} next-hop {} med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ]'.format(k, v)
32+
)
3133
if count % 100 == 0:
3234
sys.stderr.write('initial : announced %d\n' % count)
3335

qa/self/operational/operational-send.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@
3030
try:
3131
time.sleep(1)
3232
if counter % 2:
33-
sys.stdout.write('announce operational adm afi ipv4 safi unicast advisory "this is dynamic message #%d"\n' % counter)
33+
sys.stdout.write(
34+
'announce operational adm afi ipv4 safi unicast advisory "this is dynamic message #%d"\n' % counter
35+
)
3436
sys.stdout.flush()
3537
else:
36-
sys.stdout.write('announce operational asm afi ipv4 safi unicast advisory "we SHOULD not send asm from the API"\n')
38+
sys.stdout.write(
39+
'announce operational asm afi ipv4 safi unicast advisory "we SHOULD not send asm from the API"\n'
40+
)
3741
sys.stdout.flush()
3842

3943
counter += 1

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def filesOf(directory):
4949

5050

5151
setuptools.setup(
52-
packages=setuptools.find_namespace_packages(where="src"),
53-
package_dir={"": "src"},
52+
packages=setuptools.find_namespace_packages(where='src'),
53+
package_dir={'': 'src'},
5454
download_url=download_url,
5555
data_files=data_files,
5656
)

src/exabgp/application/healthcheck.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def system_ips(ip_ifnames, label, label_only, label_exact_match):
248248
else:
249249
mask = bin(int(mo.group('netmask'), 16)).count('1')
250250
try:
251-
ip = ip_network(f"{mo.group('ip')}/{mask}")
251+
ip = ip_network(f'{mo.group("ip")}/{mask}')
252252
except ValueError:
253253
continue
254254
if not ip.is_loopback:
@@ -428,7 +428,7 @@ def exabgp(target):
428428
else:
429429
action = 'announce'
430430
command = f'{prefix} {action}'
431-
announce = f"route {ip} next-hop {options.next_hop or 'self'}"
431+
announce = f'route {ip} next-hop {options.next_hop or "self"}'
432432

433433
if action == 'announce':
434434
announce = f'{announce} med {metric}'

src/exabgp/bgp/neighbor.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def __init__(self):
138138
# - have multiple exabgp toward one peer on the same host ( use of pid )
139139
# - have more than once connection toward a peer
140140
# - each connection has it own neihgbor (hence why identificator is not in Protocol)
141-
self.uid = f"{self._GLOBAL['uid']}"
141+
self.uid = f'{self._GLOBAL["uid"]}'
142142
self._GLOBAL['uid'] += 1
143143

144144
def infer(self):
@@ -159,7 +159,7 @@ def id(self):
159159
# This set must be unique between peer, not full draft-ietf-idr-bgp-multisession-07
160160
def index(self):
161161
if self['listen'] != 0:
162-
return f"peer-ip {self['peer-address']} listen {self['listen']}"
162+
return f'peer-ip {self["peer-address"]} listen {self["listen"]}'
163163
return self.name()
164164

165165
def make_rib(self):
@@ -185,7 +185,7 @@ def name(self):
185185
local_addr = self['local-address'] if self['peer-address'] is not None else 'auto'
186186
local_as = self['local-as'] if self['local-as'] is not None else 'auto'
187187
peer_as = self['peer-as'] if self['peer-as'] is not None else 'auto'
188-
return f"neighbor {self['peer-address']} local-ip {local_addr} local-as {local_as} peer-as {peer_as} router-id {self['router-id']} family-allowed {session}"
188+
return f'neighbor {self["peer-address"]} local-ip {local_addr} local-as {local_as} peer-as {peer_as} router-id {self["router-id"]} family-allowed {session}'
189189

190190
def families(self):
191191
# this list() is important .. as we use the function to modify self._families
@@ -492,25 +492,25 @@ def configuration(cls, neighbor, with_changes=True):
492492
f'\n\tpassive {"true" if neighbor["passive"] else "false"};\n'
493493
+ (f'\n\tlisten {neighbor["listen"]};\n' if neighbor['listen'] else '')
494494
+ (f'\n\tconnect {neighbor["connect"]};\n' if neighbor['connect'] else '')
495-
+ f"\tgroup-updates {'true' if neighbor['group-updates'] else 'false'};\n"
496-
f"\tauto-flush {'true' if neighbor['auto-flush'] else 'false'};\n"
497-
f"\tadj-rib-in {'true' if neighbor['adj-rib-in'] else 'false'};\n"
498-
f"\tadj-rib-out {'true' if neighbor['adj-rib-out'] else 'false'};\n"
495+
+ f'\tgroup-updates {"true" if neighbor["group-updates"] else "false"};\n'
496+
f'\tauto-flush {"true" if neighbor["auto-flush"] else "false"};\n'
497+
f'\tadj-rib-in {"true" if neighbor["adj-rib-in"] else "false"};\n'
498+
f'\tadj-rib-out {"true" if neighbor["adj-rib-out"] else "false"};\n'
499499
+ (f'\tmd5-password "{neighbor["md5-password"]}";\n' if neighbor['md5-password'] else '')
500500
+ f'\tmd5-base64 {md5_base64_str};\n'
501501
+ (f'\tmd5-ip "{neighbor["md5-ip"]}";\n' if not neighbor.auto_discovery else '')
502502
+ (f'\toutgoing-ttl {neighbor["outgoing-ttl"]};\n' if neighbor['outgoing-ttl'] else '')
503503
+ (f'\tincoming-ttl {neighbor["incoming-ttl"]};\n' if neighbor['incoming-ttl'] else '')
504504
+ f'\tcapability {{\n'
505-
f"\t\tasn4 {'enable' if neighbor['capability']['asn4'] else 'disable'};\n"
506-
f"\t\troute-refresh {'enable' if neighbor['capability']['route-refresh'] else 'disable'};\n"
507-
f"\t\tgraceful-restart {neighbor['capability']['graceful-restart'] if neighbor['capability']['graceful-restart'] else 'disable'};\n"
508-
f"\t\tsoftware-version {'enable' if neighbor['capability']['software-version'] else 'disable'};\n"
509-
f"\t\tnexthop {'enable' if neighbor['capability']['nexthop'] else 'disable'};\n"
510-
f"\t\tadd-path {add_path_str};\n"
511-
f"\t\tmulti-session {'enable' if neighbor['capability']['multi-session'] else 'disable'};\n"
512-
f"\t\toperational {'enable' if neighbor['capability']['operational'] else 'disable'};\n"
513-
f"\t\taigp {'enable' if neighbor['capability']['aigp'] else 'disable'};\n"
505+
f'\t\tasn4 {"enable" if neighbor["capability"]["asn4"] else "disable"};\n'
506+
f'\t\troute-refresh {"enable" if neighbor["capability"]["route-refresh"] else "disable"};\n'
507+
f'\t\tgraceful-restart {neighbor["capability"]["graceful-restart"] if neighbor["capability"]["graceful-restart"] else "disable"};\n'
508+
f'\t\tsoftware-version {"enable" if neighbor["capability"]["software-version"] else "disable"};\n'
509+
f'\t\tnexthop {"enable" if neighbor["capability"]["nexthop"] else "disable"};\n'
510+
f'\t\tadd-path {add_path_str};\n'
511+
f'\t\tmulti-session {"enable" if neighbor["capability"]["multi-session"] else "disable"};\n'
512+
f'\t\toperational {"enable" if neighbor["capability"]["operational"] else "disable"};\n'
513+
f'\t\taigp {"enable" if neighbor["capability"]["aigp"] else "disable"};\n'
514514
f'\t}}\n'
515515
f'\tfamily {{{families}\n'
516516
f'\t}}\n'
@@ -586,29 +586,29 @@ def as_dict(cls, answer):
586586
def formated_dict(cls, answer):
587587
if answer['duration']:
588588
duration_value = timedelta(seconds=answer['duration'])
589-
duration = f" {'up for':<20} {str(duration_value):>15} {'':<15} {'':<15}"
589+
duration = f' {"up for":<20} {str(duration_value):>15} {"":<15} {"":<15}'
590590
else:
591591
down_value = timedelta(seconds=answer['down'])
592-
duration = f" {'down for':<20} {str(down_value):>15} {'':<15} {'':<15}"
592+
duration = f' {"down for":<20} {str(down_value):>15} {"":<15} {"":<15}'
593593

594594
formated = {
595595
'peer-address': answer['peer-address'],
596-
'local-address': f" {'local':<20} {answer['local-address']:>15} {'':<15} {'':<15}",
597-
'state': f" {'state':<20} {answer['state']:>15} {'':<15} {'':<15}",
596+
'local-address': f' {"local":<20} {answer["local-address"]:>15} {"":<15} {"":<15}',
597+
'state': f' {"state":<20} {answer["state"]:>15} {"":<15} {"":<15}',
598598
'duration': duration,
599-
'as': f" {'AS':<20} {answer['local-as']:>15} {_pr(answer['peer-as']):>15} {'':<15}",
600-
'id': f" {'ID':<20} {answer['local-id']:>15} {_pr(answer['peer-id']):>15} {'':<15}",
601-
'hold': f" {'hold-time':<20} {answer['local-hold']:>15} {_pr(answer['peer-hold']):>15} {'':<15}",
599+
'as': f' {"AS":<20} {answer["local-as"]:>15} {_pr(answer["peer-as"]):>15} {"":<15}',
600+
'id': f' {"ID":<20} {answer["local-id"]:>15} {_pr(answer["peer-id"]):>15} {"":<15}',
601+
'hold': f' {"hold-time":<20} {answer["local-hold"]:>15} {_pr(answer["peer-hold"]):>15} {"":<15}',
602602
'capabilities': '\n'.join(
603-
f" {f'{k}:':<20} {_en(lc):>15} {_en(pc):>15} {'':<15}"
603+
f' {f"{k}:":<20} {_en(lc):>15} {_en(pc):>15} {"":<15}'
604604
for k, (lc, pc) in answer['capabilities'].items()
605605
),
606606
'families': '\n'.join(
607-
f" {f'{a} {s}:':<20} {_en(lf):>15} {_en(rf):>15} {_addpath(aps, apr):<15}"
607+
f' {f"{a} {s}:":<20} {_en(lf):>15} {_en(rf):>15} {_addpath(aps, apr):<15}'
608608
for (a, s), (lf, rf, apr, aps) in answer['families'].items()
609609
),
610610
'messages': '\n'.join(
611-
f" {f'{k}:':<20} {ms!s:>15} {mr!s:>15} {'':<15}" for k, (ms, mr) in answer['messages'].items()
611+
f' {f"{k}:":<20} {ms!s:>15} {mr!s:>15} {"":<15}' for k, (ms, mr) in answer['messages'].items()
612612
),
613613
}
614614

src/exabgp/configuration/neighbor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def _post_capa_rr(self, neighbor):
238238
if neighbor['capability']['route-refresh']:
239239
if not neighbor['adj-rib-out']:
240240
log.warning(
241-
lambda: f"route-refresh enabled but adj-rib-out disabled for {neighbor['peer-address']}, auto-enabling adj-rib-out",
241+
lambda: f'route-refresh enabled but adj-rib-out disabled for {neighbor["peer-address"]}, auto-enabling adj-rib-out',
242242
'configuration',
243243
)
244244
neighbor['adj-rib-out'] = True

src/exabgp/environment/environment.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def default(cls):
4747
if values['write'] in (parsing.list, parsing.path, parsing.quote, parsing.syslog_name)
4848
else values['value']
4949
)
50-
yield f"{base.APPLICATION}.{section}.{option} {' ' * (18 - len(section) - len(option))} {values['help']}. default ({default})"
50+
yield f'{base.APPLICATION}.{section}.{option} {" " * (18 - len(section) - len(option))} {values["help"]}. default ({default})'
5151

5252
@classmethod
5353
def iter_ini(cls, diff=False):
@@ -64,7 +64,7 @@ def iter_ini(cls, diff=False):
6464
if header:
6565
yield header
6666
header = ''
67-
yield f"{k} = {cls.definition[section][k]['write'](v)}"
67+
yield f'{k} = {cls.definition[section][k]["write"](v)}'
6868

6969
@classmethod
7070
def iter_env(cls, diff=False):
@@ -79,7 +79,7 @@ def iter_env(cls, diff=False):
7979
if cls.definition[section][k]['write'] == parsing.quote:
8080
yield f"{base.APPLICATION}.{section}.{k}='{v}'"
8181
continue
82-
yield f"{base.APPLICATION}.{section}.{k}={cls.definition[section][k]['write'](v)}"
82+
yield f'{base.APPLICATION}.{section}.{k}={cls.definition[section][k]["write"](v)}'
8383

8484
@classmethod
8585
def setup(cls, configuration):

src/exabgp/reactor/api/response/text.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ def _counter(self, neighbor):
3030
return None
3131

3232
def up(self, neighbor):
33-
return f"neighbor {neighbor['peer-address']} up\n"
33+
return f'neighbor {neighbor["peer-address"]} up\n'
3434

3535
def connected(self, neighbor):
36-
return f"neighbor {neighbor['peer-address']} connected\n"
36+
return f'neighbor {neighbor["peer-address"]} connected\n'
3737

3838
def down(self, neighbor, reason=''):
39-
return f"neighbor {neighbor['peer-address']} down - {reason}\n"
39+
return f'neighbor {neighbor["peer-address"]} down - {reason}\n'
4040

4141
def shutdown(self):
4242
return f'shutdown {os.getpid()} {os.getppid()}\n'
@@ -53,21 +53,21 @@ def signal(self, neighbor, signal):
5353
def notification(self, neighbor, direction, message, negotiated, header, body):
5454
data_hex = hexstring(message.data)
5555
header_body = self._header_body(header, body)
56-
return f"neighbor {neighbor['peer-address']} {direction} notification code {message.code} subcode {message.subcode} data {data_hex}{header_body}\n"
56+
return f'neighbor {neighbor["peer-address"]} {direction} notification code {message.code} subcode {message.subcode} data {data_hex}{header_body}\n'
5757

5858
def packets(self, neighbor, direction, category, negotiated, header, body):
59-
return f"neighbor {neighbor['peer-address']} {direction} {category}{self._header_body(header, body)}\n"
59+
return f'neighbor {neighbor["peer-address"]} {direction} {category}{self._header_body(header, body)}\n'
6060

6161
def keepalive(self, neighbor, direction, negotiated, header, body):
62-
return f"neighbor {neighbor['peer-address']} {direction} keepalive{self._header_body(header, body)}\n"
62+
return f'neighbor {neighbor["peer-address"]} {direction} keepalive{self._header_body(header, body)}\n'
6363

6464
def open(self, neighbor, direction, sent_open, negotiated, header, body):
6565
capabilities_str = str(sent_open.capabilities).lower()
6666
header_body = self._header_body(header, body)
67-
return f"neighbor {neighbor['peer-address']} {direction} open version {sent_open.version} asn {sent_open.asn} hold_time {sent_open.hold_time} router_id {sent_open.router_id} capabilities [{capabilities_str}]{header_body}\n"
67+
return f'neighbor {neighbor["peer-address"]} {direction} open version {sent_open.version} asn {sent_open.asn} hold_time {sent_open.hold_time} router_id {sent_open.router_id} capabilities [{capabilities_str}]{header_body}\n'
6868

6969
def update(self, neighbor, direction, update, negotiated, header, body):
70-
prefix = f"neighbor {neighbor['peer-address']} {direction} update"
70+
prefix = f'neighbor {neighbor["peer-address"]} {direction} update'
7171

7272
r = f'{prefix} start\n'
7373

@@ -91,16 +91,16 @@ def update(self, neighbor, direction, update, negotiated, header, body):
9191
return r
9292

9393
def refresh(self, neighbor, direction, refresh, negotiated, header, body):
94-
return f"neighbor {neighbor['peer-address']} {direction} route-refresh afi {refresh.afi} safi {refresh.safi} {refresh.reserved}{self._header_body(header, body)}\n"
94+
return f'neighbor {neighbor["peer-address"]} {direction} route-refresh afi {refresh.afi} safi {refresh.safi} {refresh.reserved}{self._header_body(header, body)}\n'
9595

9696
def _operational_advisory(self, neighbor, direction, operational, header, body):
97-
return f"neighbor {neighbor['peer-address']} {direction} operational {operational.name} afi {operational.afi} safi {operational.safi} advisory \"{operational.data}\"{self._header_body(header, body)}"
97+
return f'neighbor {neighbor["peer-address"]} {direction} operational {operational.name} afi {operational.afi} safi {operational.safi} advisory "{operational.data}"{self._header_body(header, body)}'
9898

9999
def _operational_query(self, neighbor, direction, operational, header, body):
100-
return f"neighbor {neighbor['peer-address']} {direction} operational {operational.name} afi {operational.afi} safi {operational.safi}{self._header_body(header, body)}"
100+
return f'neighbor {neighbor["peer-address"]} {direction} operational {operational.name} afi {operational.afi} safi {operational.safi}{self._header_body(header, body)}'
101101

102102
def _operational_counter(self, neighbor, direction, operational, header, body):
103-
return f"neighbor {neighbor['peer-address']} {direction} operational {operational.name} afi {operational.afi} safi {operational.safi} router-id {operational.routerid} sequence {operational.sequence} counter {operational.counter}{self._header_body(header, body)}"
103+
return f'neighbor {neighbor["peer-address"]} {direction} operational {operational.name} afi {operational.afi} safi {operational.safi} router-id {operational.routerid} sequence {operational.sequence} counter {operational.counter}{self._header_body(header, body)}'
104104

105105
def operational(self, neighbor, direction, what, operational, negotiated, header, body):
106106
if what == 'advisory':

src/exabgp/reactor/protocol.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def fd(self):
8080
# XXX: we use self.peer.neighbor['peer-address'] when we could use self.neighbor['peer-address']
8181

8282
def me(self, message):
83-
return f"{self.peer.neighbor['peer-address']}/{self.peer.neighbor['peer-as']} {message}"
83+
return f'{self.peer.neighbor["peer-address"]}/{self.peer.neighbor["peer-as"]} {message}'
8484

8585
def accept(self, incoming):
8686
self.connection = incoming

0 commit comments

Comments
 (0)