-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1791994 IR: Generate typed protobuf Python code #2593
Conversation
9f796a2
to
6d9ab25
Compare
c7e0af0
to
6e576e7
Compare
6e576e7
to
3cf6597
Compare
3cf6597
to
6fb5f1b
Compare
run: | | ||
make clean | ||
make html SPHINXOPTS="-W --keep-going" | ||
run: python -m tox -e docs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just reuse the same code in tox
@@ -91,6 +91,7 @@ repos: | |||
- id: mypy | |||
files: > | |||
(?x)^( | |||
src/snowflake/snowpark/_internal/ast/.*\.py| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cover all ast code in mypy type check
@@ -80,14 +80,14 @@ def __init__(self) -> None: # pragma: no cover | |||
self.symbols: Optional[Union[str, List[str]]] = None | |||
|
|||
# TODO(SNOW-1491199) - This method is not covered by tests until the end of phase 0. Drop the pragma when it is covered. | |||
def visit_Assign(self, node) -> None: # pragma: no cover | |||
def visit_Assign(self, node: ast.Assign) -> None: # pragma: no cover |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should fix those once our code is in.
): | ||
stmt = func._ast_stmt | ||
fn_expr = expr.fn.indirect_table_fn_id_ref | ||
stmt = func._ast_stmt # type: ignore[union-attr] # TODO(SNOW-1491199) # Item "str" of "Union[str, list[str], TableFunctionCall, Callable[..., Any]]" has no attribute "_ast_stmt", Item "list[str]" of "Union[str, list[str], TableFunctionCall, Callable[..., Any]]" has no attribute "_ast_stmt", Item "TableFunctionCall" of "Union[str, list[str], TableFunctionCall, Callable[..., Any]]" has no attribute "_ast_stmt", Item "function" of "Union[str, list[str], TableFunctionCall, Callable[..., Any]]" has no attribute "_ast_stmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the comments are machine-generated. Does any particular linter or annotation checker require the full message? Looks pretty cumbersome.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it contains three parts:
- jira no. to track
- the type ignore
- the error message
It's probably verbose for the error message but I try to capture them so when we fix them later, we can easily know what was the issue before.
Thank you for setting this up! Generally looks good. I did not review |
@@ -57,6 +57,7 @@ | |||
"pytest-assume", # sql counter check | |||
"decorator", # sql counter check | |||
"protoc-wheel-0==21.1", # Protocol buffer compiler, for Snowpark IR | |||
"mypy-protobuf", # used in generating typed Python code from protobuf for Snowpark IR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this has no licensing or security concerns, either. Should this require a specific minimum version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is development requirements so should be fine.
Which Jira issue is this PR addressing? Make sure that there is an accompanying issue to your PR.
Fixes SNOW-1791994
Fill out the following pre-review checklist:
Please describe how your code solves the related issue.
Please write a short description of how your code change solves the related issue.
This PR generates typed Python code from protobuf and make sure CI check types in precommit.
Copilot summary:
This pull request includes several changes to improve type checking, streamline the build process, and enhance code quality. The most important changes include the addition of
mypy-protobuf
for generating typed Python code from protobuf, updates to the build and pre-commit configurations, and improvements to type annotations across various files.Build and Dependency Management:
mypy-protobuf
installation in.github/scripts/install_protoc.sh
andscripts/jenkins_regress.sh
to generate typed Python code from protobuf. [1] [2] [3].github/workflows/precommit.yml
to installtox
and streamline the documentation build process usingtox
.setup.py
to includemypy-protobuf
as a dependency and updated the protobuf generation command to use--mypy_out
. [1] [2] [3]Pre-commit Configuration:
mypy
check in.pre-commit-config.yaml
. [1] [2]Code Quality and Type Annotations:
src/snowflake/snowpark/_internal/ast/batch.py
by specifying return types and dictionary types. [1] [2] [3]src/snowflake/snowpark/_internal/ast/utils.py
by adding# type: ignore
comments and TODOs for better handling of type issues. [1] [2] [3] [4] [5] [6]Tested Jenkins jobs: