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

Adding type check for serve.py #1652

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ishaanagw
Copy link

No description provided.

@ishaanagw
Copy link
Author

Hey @philippmwirth, please review this MR. Thanks.

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 84.70%. Comparing base (34aa499) to head (2780290).

Files with missing lines Patch % Lines
lightly/api/serve.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1652   +/-   ##
=======================================
  Coverage   84.70%   84.70%           
=======================================
  Files         151      151           
  Lines        6446     6446           
=======================================
  Hits         5460     5460           
  Misses        986      986           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@SauravMaheshkar SauravMaheshkar left a comment

Choose a reason for hiding this comment

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

LGTM ❤️

@SauravMaheshkar SauravMaheshkar linked an issue Sep 23, 2024 that may be closed by this pull request
@SauravMaheshkar
Copy link
Collaborator

Partly fixes #1635

@ishaanagw
Copy link
Author

Hey, thanks, very new to this open source, can you also merge it ? or do you guys follow some release timelines ?

@SauravMaheshkar
Copy link
Collaborator

Hey, thanks, very new to this open source, can you also merge it ? or do you guys follow some release timelines ?

Hello 👋🏽 , I think in order for this PR to count for your Hacktoberfest total we'd have to merge it between Oct 1-31. I'm going to wait on @guarin for this.

@ishaanagw
Copy link
Author

Ohh, but I am not doing it for hacktober fest, so if you can merge it then please go ahead, Thanks.

Copy link
Contributor

@guarin guarin left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR! There is one small thing that needs changing before we can merge it, sorry for the annoyance. I'll update the issue description to reflect that we need older type hints.

@@ -42,7 +42,7 @@ def do_OPTIONS(self) -> None:
self.send_header("Access-Control-Allow-Methods", "GET, POST, OPTIONS")
self.end_headers()

def send_response_only(self, code, message=None):
def send_response_only(self, code: int, message: str | None = None) -> None:
Copy link
Contributor

@guarin guarin Sep 24, 2024

Choose a reason for hiding this comment

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

Could you change this to use Optional (can be imported with from typing import Optional)?

Suggested change
def send_response_only(self, code: int, message: str | None = None) -> None:
def send_response_only(self, code: int, message: Optional[str= None) -> None:

The package is still used on some older Python versions (<3.10) which do not yet support the new X | Y typing syntax introduced in 3.10. This is usually caught by our tests but this specific function is not tested :(

Edit: Actually, let's just add from __future__ import annotations at the top of the file. Then Python 3.10 types are also supported on older versions.

Copy link
Author

Choose a reason for hiding this comment

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

okay, will add and crate a PR

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to create a new PR, you can just update this one.

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.

3 participants