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

typing updates for Task #194

Merged
merged 2 commits into from
Jul 3, 2024
Merged

typing updates for Task #194

merged 2 commits into from
Jul 3, 2024

Conversation

albertz
Copy link
Member

@albertz albertz commented Jul 3, 2024

Also removed Python 2 style code to derive from object.

I did not cover update_rqmt yet because this would require Protocol (not just Callable), and I'm not sure if we want that (requires Python 3.8).

Also removed Python 2 style code to derive from object.

I did not cover update_rqmt yet
because this would require Protocol (not just Callable),
and I'm not sure if we want that (requires Python 3.8).
Requires Python 3.7. At least the CI here is run with Python 3.6, thus does not support it...
start: str,
resume: Optional[str] = None,
rqmt: Optional[Dict[str, Any]] = None,
args: Optional[Sequence[Union[List[Any], Any]]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
args: Optional[Sequence[Union[List[Any], Any]]] = None,
args: Optional[Sequence[Any]] = None,

can already be Any and List[Any] is contained in Any.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea I know, but sometimes I prefer this to give some more specific type hints to what types would be specifically expected here, or specially handled, even though other types (any other types) would also be ok.

Also, I basically just translated the typing from the earlier docstring. I also wondered a bit about why this is here at all, and I thought there is indeed maybe a special meaning when there is a list?

@michelwi
Copy link
Contributor

michelwi commented Jul 3, 2024

did not cover update_rqmt yet because this would require Protocol (not just Callable), and I'm not sure if we want that

Why would Callable[[Dict[str, Any], Dict[str, Any]], Dict[str, Any]] not work?

@albertz
Copy link
Member Author

albertz commented Jul 3, 2024

did not cover update_rqmt yet because this would require Protocol (not just Callable), and I'm not sure if we want that

Why would Callable[[Dict[str, Any], Dict[str, Any]], Dict[str, Any]] not work?

We call self._update_rqmt(last_rqmt=last_rqmt, last_usage=last_usage), i.e. we use named args, which is not supported by Callable.

Copy link
Member

@NeoLegends NeoLegends left a comment

Choose a reason for hiding this comment

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

👍

@albertz albertz merged commit 58694e6 into master Jul 3, 2024
3 checks passed
@albertz albertz deleted the albert-fix-some-typing branch July 3, 2024 11:50
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