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

Conversation

savarin
Copy link
Contributor

@savarin savarin commented Feb 20, 2024

Describe your changes

This PR adds mypy types to modal_version and modal_utils, as per #1372.

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

Copy link

@modal-pr-review-automation modal-pr-review-automation bot left a comment

Choose a reason for hiding this comment

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

Auto-approved 👍. This diff qualified for automatic approval and doesn't need follow up review.

@@ -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

@freider
Copy link
Contributor

freider commented Feb 23, 2024

I updated the repo to use pyright instead of mypy for checking implemenation files, since mypy seems basically broken in this regard. See: #1403

@savarin
Copy link
Contributor Author

savarin commented Feb 27, 2024

I updated the repo to use pyright instead of mypy for checking implemenation files, since mypy seems basically broken in this regard. See: #1403

@freider Sounds good! Sorry for delay, had been away last week and into this week. I'll take a look at #1403.

@freider
Copy link
Contributor

freider commented Feb 28, 2024

I updated the repo to use pyright instead of mypy for checking implemenation files, since mypy seems basically broken in this regard. See: #1403

@freider Sounds good! Sorry for delay, had been away last week and into this week. I'll take a look at #1403.

Just merged #1403 so it should be straight-forward to take on typing fixes for additional files now if you want to :)

@savarin
Copy link
Contributor Author

savarin commented Feb 29, 2024

Just merged #1403 so it should be straight-forward to take on typing fixes for additional files now if you want to :)

@freider Thanks for the heavy lifting! I'm afraid I haven't gotten the chance to take a closer look at pyright (or at least don't completely follow errors) but can move tad slower and go for the low hanging fruit first as I feel my way around - created #1438 to keep things moving.

@savarin savarin closed this Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants