Skip to content

Commit d5ff7d4

Browse files
committed
Merge remote-tracking branch 'upstream/main' into poc/agent-catalog
Signed-off-by: Shingo OKAWA <[email protected]>
2 parents 5886b54 + 2c4f1a7 commit d5ff7d4

Some content is hidden

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

43 files changed

+1531
-1570
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ Before submitting your PR, there are a few things you can do to make sure it goe
55

66
- [ ] Follow the [`CONTRIBUTING` Guide](https://github.com/google-a2a/a2a-python/blob/main/CONTRIBUTING.md).
77
- [ ] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification.
8+
- Important Prefixes for [release-please](https://github.com/googleapis/release-please):
9+
- `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch.
10+
- `feat:` represents a new feature, and correlates to a SemVer minor.
11+
- `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major.
812
- [ ] Ensure the tests and linter pass (Run `nox -s format` from the repository root to format)
913
- [ ] Appropriate docs were updated (if necessary)
1014

.github/actions/spelling/allow.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ACard
22
AClient
33
AError
4+
AFast
45
ARequest
56
ARun
67
AServer
@@ -39,6 +40,7 @@ oauthoidc
3940
ognis
4041
opensource
4142
poc
43+
protoc
4244
pyversions
4345
socio
4446
sse

.github/linters/.jscpd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"ignore": ["**/.github/**", "**/.git/**", "**/tests/**", "**/examples/**"],
2+
"ignore": ["**/.github/**", "**/.git/**", "**/tests/**"],
33
"threshold": 3,
44
"reporters": ["html", "markdown"]
55
}

.ruff.toml renamed to .github/linters/.ruff.toml

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@ target-version = "py310" # Minimum Python version
1313

1414
[lint]
1515
ignore = [
16-
"COM812",
17-
"FBT001",
18-
"FBT002",
19-
"D203",
20-
"D213",
21-
"ANN001",
22-
"ANN201",
23-
"ANN204",
24-
"D100", # Ignore Missing docstring in public module (often desired at top level __init__.py)
25-
"D102", # Ignore return type annotation in public method
26-
"D104", # Ignore Missing docstring in public package (often desired at top level __init__.py)
27-
"D107", # Ignore Missing docstring in __init__ (use class docstring)
28-
"TD002", # Ignore Missing author in TODOs (often not required)
29-
"TD003", # Ignore Missing issue link in TODOs (often not required/available)
30-
"T201", # Ignore print presence
16+
"COM812", # Trailing comma missing.
17+
"FBT001", # Boolean positional arg in function definition
18+
"FBT002", # Boolean default value in function definition
19+
"D203", # 1 blank line required before class docstring (Google: 0)
20+
"D213", # Multi-line docstring summary should start at the second line (Google: first line)
21+
"D100", # Ignore Missing docstring in public module (often desired at top level __init__.py)
22+
"D104", # Ignore Missing docstring in public package (often desired at top level __init__.py)
23+
"D107", # Ignore Missing docstring in __init__ (use class docstring)
24+
"TD002", # Ignore Missing author in TODOs (often not required)
25+
"TD003", # Ignore Missing issue link in TODOs (often not required/available)
26+
"T201", # Ignore print presence
3127
"RUF012", # Ignore Mutable class attributes should be annotated with `typing.ClassVar`
32-
"RUF013", # Ignore implicit optional
28+
"E501", # Ignore line length (handled by Ruff's dynamic line length)
29+
"ANN002",
30+
"ANN003",
31+
"ANN401",
3332
]
3433

3534
select = [
@@ -50,12 +49,14 @@ select = [
5049
"PTH",# flake8-use-pathlib (use pathlib instead of os.path where possible)
5150
"PL", # Pylint rules ported to Ruff (PLC, PLE, PLR, PLW)
5251
"PIE",# flake8-pie (misc code improvements, e.g., no-unnecessary-pass)
53-
"RUF",# Ruff-specific rules (e.g., RUF001-003 ambiguous unicode)
52+
"RUF",# Ruff-specific rules (e.g., RUF001-003 ambiguous unicode, RUF013 implicit optional)
5453
"RET",# flake8-return (consistency in return statements)
5554
"SLF",# flake8-self (check for private member access via `self`)
5655
"TID",# flake8-tidy-imports (relative imports, banned imports - configure if needed)
5756
"YTT",# flake8-boolean-trap (checks for boolean positional arguments, truthiness tests - Google Style §3.10)
5857
"TD", # flake8-todos (check TODO format - Google Style §3.7)
58+
"TCH",# flake8-type-checking (helps manage TYPE_CHECKING blocks and imports)
59+
"PYI",# flake8-pyi (best practices for .pyi stub files, some rules are useful for .py too)
5960
]
6061

6162
exclude = [
@@ -80,7 +81,7 @@ exclude = [
8081
"node_modules",
8182
"venv",
8283
"*/migrations/*",
83-
"test_*",
84+
"noxfile.py",
8485
]
8586

8687
[lint.isort]
@@ -98,6 +99,8 @@ lines-between-types = 1
9899

99100
[lint.pydocstyle]
100101
convention = "google"
102+
ignore-decorators = ["typing.overload", "abc.abstractmethod"]
103+
ignore-var-parameters = true
101104

102105
[lint.flake8-annotations]
103106
mypy-init-return = true
@@ -116,12 +119,27 @@ docstring-quotes = "double"
116119
inline-quotes = "single"
117120

118121
[lint.per-file-ignores]
119-
"__init__.py" = ["F401"] # Ignore unused imports in __init__.py
120-
"*_test.py" = ["D", "ANN"] # Ignore docstring and annotation issues in test files
121-
"test_*.py" = ["D", "ANN"] # Ignore docstring and annotation issues in test files
122+
"__init__.py" = ["F401", "D", "ANN"] # Ignore unused imports in __init__.py
123+
"*_test.py" = [
124+
"D", # All pydocstyle rules
125+
"ANN", # Missing type annotation for function argument
126+
"RUF013", # Implicit optional type in test function signatures
127+
"S101", # Use of `assert` detected (expected in tests)
128+
"PLR2004",
129+
"SLF001",
130+
]
131+
"test_*.py" = [
132+
"D",
133+
"ANN",
134+
"RUF013",
135+
"S101",
136+
"PLR2004",
137+
"SLF001",
138+
]
122139
"types.py" = ["D", "E501", "N815"] # Ignore docstring and annotation issues in types.py
123140

124141
[format]
142+
exclude = ["types.py"]
125143
docstring-code-format = true
126144
docstring-code-line-length = "dynamic" # Or set to 80
127145
quote-style = "single"

.github/workflows/linter.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ jobs:
6363
VALIDATE_TYPESCRIPT_STANDARD: false
6464
VALIDATE_GIT_COMMITLINT: false
6565
PYTHON_MYPY_CONFIG_FILE: .mypy.ini
66-
FILTER_REGEX_INCLUDE: "^src/**"
66+
FILTER_REGEX_INCLUDE: ".*src/**/*"
67+
PYTHON_RUFF_CONFIG_FILE: .ruff.toml

.vscode/settings.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,17 @@
77
"editor.defaultFormatter": "charliermarsh.ruff",
88
"editor.formatOnSave": true,
99
"editor.codeActionsOnSave": {
10-
"source.organizeImports": "always"
10+
"source.organizeImports": "always",
11+
"source.fixAll.ruff": "explicit"
1112
}
1213
},
13-
"ruff.importStrategy": "fromEnvironment"
14+
"ruff.importStrategy": "fromEnvironment",
15+
"ruff.lint.args": [
16+
"--config",
17+
".github/linters/.ruff.toml"
18+
],
19+
"ruff.format.args": [
20+
"--config",
21+
".github/linters/.ruff.toml"
22+
]
1423
}

buf.gen.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
version: v2
2+
inputs:
3+
- git_repo: https://github.com/google-a2a/A2A.git
4+
ref: main
5+
subdir: specification/grpc
6+
managed:
7+
enabled: true
8+
# Python Generation
9+
# Using remote plugins. To use local plugins replace remote with local
10+
# pip install protobuf grpcio-tools
11+
# Optionally, install plugin to generate stubs for grpc services
12+
# pip install mypy-protobuf
13+
# Generate python protobuf code
14+
# - local: protoc-gen-python
15+
# - out: src/python
16+
# Generate gRPC stubs
17+
# - local: protoc-gen-grpc-python
18+
# - out: src/python
19+
plugins:
20+
# Generate python protobuf related code
21+
# Generates *_pb2.py files, one for each .proto
22+
- remote: buf.build/protocolbuffers/python
23+
out: src/a2a/grpc
24+
# Generate python service code.
25+
# Generates *_pb2_grpc.py
26+
- remote: buf.build/grpc/python
27+
out: src/a2a/grpc

noxfile.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
@nox.session(python=DEFAULT_PYTHON_VERSION)
39-
def format(session):
39+
def format(session) -> None:
4040
"""Format Python code using autoflake, pyupgrade, and ruff."""
4141
# Sort Spelling Allowlist
4242
spelling_allow_file = '.github/actions/spelling/allow.txt'
@@ -141,10 +141,14 @@ def format(session):
141141
'ruff',
142142
'check',
143143
'--fix-only',
144+
'--config',
145+
'.github/linters/.ruff.toml',
144146
*lint_paths_py,
145147
)
146148
session.run(
147149
'ruff',
148150
'format',
151+
'--config',
152+
'.github/linters/.ruff.toml',
149153
*lint_paths_py,
150154
)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ authors = [{ name = "Google LLC", email = "[email protected]" }]
88
requires-python = ">=3.10"
99
keywords = ["A2A", "A2A SDK", "A2A Protocol", "Agent2Agent"]
1010
dependencies = [
11+
"fastapi>=0.115.12",
1112
"httpx>=0.28.1",
1213
"httpx-sse>=0.4.0",
1314
"opentelemetry-api>=1.33.0",

src/a2a/auth/user.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ class UnauthenticatedUser(User):
2121
"""A representation that no user has been authenticated in the request."""
2222

2323
@property
24-
def is_authenticated(self):
24+
def is_authenticated(self) -> bool:
25+
"""Returns whether the current user is authenticated."""
2526
return False
2627

2728
@property
2829
def user_name(self) -> str:
30+
"""Returns the user name of the current user."""
2931
return ''

0 commit comments

Comments
 (0)