Skip to content
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

Add types to modal_version and modal_utils #1374

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modal/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ async def _stream_function_call_data(
while True:
req = api_pb2.FunctionCallGetDataRequest(function_call_id=function_call_id, last_index=last_index)
try:
async for chunk in unary_stream(stub_fn, req):
async for chunk in unary_stream(stub_fn, req): # type: ignore[var-annotated]
Copy link
Contributor Author

@savarin savarin Feb 20, 2024

Choose a reason for hiding this comment

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

@freider I'm a little puzzled why this now raises a mypy error, since unary_stream returns AsyncIterator[_RecvType].

) -> AsyncIterator[_RecvType]:

Not sure why this isn't picked up in functions.py.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's due to --follow-imports=skip, so the imported type isn't available (removing that flag, this error disappears but you get tons of errors in the imported files instead...). I wonder if there is a way to check a single file for type errors but still follow imports in order to get types

Copy link
Contributor

Choose a reason for hiding this comment

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

Would prefer not to have unnecessary # type: ignores in places just because mypy can't properly traverse things. The only case I think we should need it is when a .py-file references a type that's only defined in the same file's .pyi file, since I doubt we can get mypy to actually read both

if chunk.index <= last_index:
continue
last_index = chunk.index
Expand Down
12 changes: 12 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ def lint(ctx):
def mypy(ctx):
mypy_allowlist = [
"modal/functions.py",
"modal_utils/__init__.py",
"modal_utils/app_utils.py",
"modal_utils/async_utils.py",
"modal_utils/grpc_testing.py",
"modal_utils/grpc_utils.py",
"modal_utils/hash_utils.py",
"modal_utils/http_utils.py",
"modal_utils/logger.py",
"modal_utils/package_utils.py",
"modal_utils/rand_pb_testing.py",
"modal_version/__init__.py",
"modal_version/_version_generated.py",
]

ctx.run("mypy .", pty=True)
Expand Down
Loading