Skip to content

[Python] [Pyright] Part 1 - Pyright for src/python/grpcio/grpc/aio/_base_server.py#42240

Closed
asheshvidyut wants to merge 9 commits into
grpc:masterfrom
asheshvidyut:feature/python/pyright-part-1
Closed

[Python] [Pyright] Part 1 - Pyright for src/python/grpcio/grpc/aio/_base_server.py#42240
asheshvidyut wants to merge 9 commits into
grpc:masterfrom
asheshvidyut:feature/python/pyright-part-1

Conversation

@asheshvidyut

@asheshvidyut asheshvidyut commented Apr 26, 2026

Copy link
Copy Markdown
Member

Description

This is Part 1 of adding Pyright to AIO stack adds Pyright to src/python/grpcio/grpc/aio/_base_server.py

Testing

CI

Previous

Next

@asheshvidyut asheshvidyut added the release notes: yes Indicates if PR needs to be in release notes label Apr 26, 2026
@asheshvidyut asheshvidyut marked this pull request as ready for review April 26, 2026 02:56
@asheshvidyut asheshvidyut changed the title [Introducing Pyright] Part 1 - Pyright for src/python/grpcio/grpc/aio/_base_server.py [Python] [Introducing Pyright] Part 1 - Pyright for src/python/grpcio/grpc/aio/_base_server.py Apr 26, 2026
@asheshvidyut asheshvidyut changed the title [Python] [Introducing Pyright] Part 1 - Pyright for src/python/grpcio/grpc/aio/_base_server.py [Python] [Pyright] Part 1 - Pyright for src/python/grpcio/grpc/aio/_base_server.py Apr 26, 2026
@asheshvidyut asheshvidyut requested review from sergiitk and sreenithi and removed request for sreenithi April 26, 2026 03:10

@sreenithi sreenithi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just had one comment.

Comment thread pyproject.toml
Comment on lines +91 to +93
[[tool.pyright.executionEnvironments]]
root = "src/python/grpcio_tests"
extraPaths = ["src/python/grpcio"] No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this doesn't have any meaning in this PR because we are not checking any file in src/python/grpcio_tests.

You can keep it here if you need it as a pre-requisite for future PRs or remove it here and add it in later PRs when you enable pyright in files in grpcio_tests. I'm fine either way

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will prefer to keep it. Thanks.

Comment thread pyproject.toml
Comment thread tools/distrib/pyright_code.sh
Comment thread tools/distrib/pyright_code.sh Outdated
Comment thread tools/distrib/pyright_code.sh Outdated
Comment thread tools/distrib/pyright_code.sh Outdated
source $VIRTUALENV/bin/activate
python3 --version

pip install pyright

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's lock it to the latest now

asheshvidyut and others added 5 commits April 28, 2026 12:30
Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
Co-authored-by: Sergii Tkachenko <sergiitk@google.com>
@copybara-service copybara-service Bot closed this in d2e1ff8 May 4, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 9, 2026
…all.py (#42272)

# Description

This is Part 2 of adding Pyright to AIO stack adds `Pyright` to `src/python/grpcio/grpc/aio/_call.py`

# Errors

```
+ [03:02:03 UTC]         exec pyright
  _call.py:34:26 - error: "cygrpc" is unknown import symbol (reportAttributeAccessIssue)
  _call.py:133:16 - error: Type "Metadata | None" is not assignable to return type "Metadata"
  _call.py:141:16 - error: Type "Metadata | None" is not assignable to return type "Metadata"
  _call.py:149:16 - error: Type "str | None" is not assignable to return type "str"
  _call.py:338:35 - error: Type variable "ResponseType" has no meaning in this context (reportGeneralTypeIssues)
  _call.py:343:31 - error: Cannot assign to attribute "_message_aiter" for class "_StreamResponseMixin*"
  _call.py:362:19 - error: Return type of async generator function must be compatible with "AsyncGenerator[Unknown, Any]"
  _call.py:371:35 - error: Cannot assign to attribute "_message_aiter" for class "_StreamResponseMixin*"
  _call.py:372:16 - error: Type "AsyncIterator[ResponseType]" is not assignable to return type "AsyncIterator[ResponseType@__aiter__]"
  _call.py:390:35 - error: Variable not allowed in type expression (reportInvalidTypeForm)
  _call.py:447:38 - error: "Iterable[Any]" is not iterable
  _call.py:460:32 - error: "AsyncIterable[Any]" is not iterable
  _call.py:545:15 - error: Type variable "RequestType" has no meaning in this context (reportGeneralTypeIssues)
  _call.py:608:15 - error: Type variable "RequestType" has no meaning in this context (reportGeneralTypeIssues)
  _call.py:639:44 - error: Function with declared return type "ResponseType@_send_unary_request" must return value on all code paths
15 errors, 11 warnings, 0 informations
```

# Testing

CI

# Previous

* #42240

# Next
* #42273

Closes #42272

COPYBARA_INTEGRATE_REVIEW=#42272 from asheshvidyut:feature/python/pyright-part-2 83c6502
PiperOrigin-RevId: 929268985
asheshvidyut added a commit to a-detiste/grpc that referenced this pull request Jun 10, 2026
…ase_server.py (grpc#42240)

# Description

This is Part 1 of adding Pyright to AIO stack adds `Pyright` to `src/python/grpcio/grpc/aio/_base_server.py
`

# Testing

CI

# Previous

* grpc#40353

# Next

* grpc#42272

Closes grpc#42240

COPYBARA_INTEGRATE_REVIEW=grpc#42240 from asheshvidyut:feature/python/pyright-part-1 b4680a9
PiperOrigin-RevId: 909803418
asheshvidyut added a commit to a-detiste/grpc that referenced this pull request Jun 10, 2026
…all.py (grpc#42272)

# Description

This is Part 2 of adding Pyright to AIO stack adds `Pyright` to `src/python/grpcio/grpc/aio/_call.py`

# Errors

```
+ [03:02:03 UTC]         exec pyright
  _call.py:34:26 - error: "cygrpc" is unknown import symbol (reportAttributeAccessIssue)
  _call.py:133:16 - error: Type "Metadata | None" is not assignable to return type "Metadata"
  _call.py:141:16 - error: Type "Metadata | None" is not assignable to return type "Metadata"
  _call.py:149:16 - error: Type "str | None" is not assignable to return type "str"
  _call.py:338:35 - error: Type variable "ResponseType" has no meaning in this context (reportGeneralTypeIssues)
  _call.py:343:31 - error: Cannot assign to attribute "_message_aiter" for class "_StreamResponseMixin*"
  _call.py:362:19 - error: Return type of async generator function must be compatible with "AsyncGenerator[Unknown, Any]"
  _call.py:371:35 - error: Cannot assign to attribute "_message_aiter" for class "_StreamResponseMixin*"
  _call.py:372:16 - error: Type "AsyncIterator[ResponseType]" is not assignable to return type "AsyncIterator[ResponseType@__aiter__]"
  _call.py:390:35 - error: Variable not allowed in type expression (reportInvalidTypeForm)
  _call.py:447:38 - error: "Iterable[Any]" is not iterable
  _call.py:460:32 - error: "AsyncIterable[Any]" is not iterable
  _call.py:545:15 - error: Type variable "RequestType" has no meaning in this context (reportGeneralTypeIssues)
  _call.py:608:15 - error: Type variable "RequestType" has no meaning in this context (reportGeneralTypeIssues)
  _call.py:639:44 - error: Function with declared return type "ResponseType@_send_unary_request" must return value on all code paths
15 errors, 11 warnings, 0 informations
```

# Testing

CI

# Previous

* grpc#42240

# Next
* grpc#42273

Closes grpc#42272

COPYBARA_INTEGRATE_REVIEW=grpc#42272 from asheshvidyut:feature/python/pyright-part-2 83c6502
PiperOrigin-RevId: 929268985
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants