Skip to content

Commit 41b46ce

Browse files
authored
Merge branch 'main' into auto-update-a2a-types-f355d3e922de61ba97873fe2989a8987fc89eec2
2 parents 5f7e025 + c983481 commit 41b46ce

File tree

3 files changed

+835
-508
lines changed

3 files changed

+835
-508
lines changed

scripts/grpc_gen_post_processor.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
"""
2-
Fix absolute imports in *_pb2_grpc.py files.
1+
"""Fix absolute imports in *_pb2_grpc.py files.
2+
33
Example:
44
import a2a_pb2 as a2a__pb2
55
from . import a2a_pb2 as a2a__pb2
@@ -16,40 +16,40 @@ def process_generated_code(src_folder: str = 'src/a2a/grpc'):
1616
dir_path = Path(src_folder)
1717
print(dir_path)
1818
if not dir_path.is_dir():
19-
print('Source folder not found')
20-
sys.exit(1)
19+
print('Source folder not found')
20+
sys.exit(1)
2121

2222
grpc_pattern = '**/*_pb2_grpc.py'
2323
files = dir_path.glob(grpc_pattern)
2424

2525
for file in files:
26-
print(f'Processing {file}')
27-
try:
28-
with file.open('r', encoding='utf-8') as f:
29-
src_content = f.read()
30-
31-
# Change import a2a_pb2 as a2a__pb2
32-
import_pattern = r'^import (\w+_pb2) as (\w+__pb2)$'
33-
# to from . import a2a_pb2 as a2a__pb2
34-
replacement_pattern = r'from . import \1 as \2'
35-
36-
fixed_src_content = re.sub(
37-
import_pattern,
38-
replacement_pattern,
39-
src_content,
40-
flags=re.MULTILINE,
41-
)
42-
43-
if fixed_src_content != src_content:
44-
with file.open('w', encoding='utf-8') as f:
45-
f.write(fixed_src_content)
46-
print('Imports fixed')
47-
else:
48-
print('No changes needed')
49-
50-
except Exception as e:
51-
print(f'Error processing file {file}: {e}')
52-
sys.exit(1)
26+
print(f'Processing {file}')
27+
try:
28+
with file.open('r', encoding='utf-8') as f:
29+
src_content = f.read()
30+
31+
# Change import a2a_pb2 as a2a__pb2
32+
import_pattern = r'^import (\w+_pb2) as (\w+__pb2)$'
33+
# to from . import a2a_pb2 as a2a__pb2
34+
replacement_pattern = r'from . import \1 as \2'
35+
36+
fixed_src_content = re.sub(
37+
import_pattern,
38+
replacement_pattern,
39+
src_content,
40+
flags=re.MULTILINE,
41+
)
42+
43+
if fixed_src_content != src_content:
44+
with file.open('w', encoding='utf-8') as f:
45+
f.write(fixed_src_content)
46+
print('Imports fixed')
47+
else:
48+
print('No changes needed')
49+
50+
except Exception as e:
51+
print(f'Error processing file {file}: {e}')
52+
sys.exit(1)
5353

5454

5555
if __name__ == '__main__':

src/a2a/server/events/event_consumer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async def consume_all(self) -> AsyncGenerator[Event]:
112112
TaskState.failed,
113113
TaskState.rejected,
114114
TaskState.unknown,
115-
TaskState.input_required
115+
TaskState.input_required,
116116
)
117117
)
118118
)

0 commit comments

Comments
 (0)