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

added return types for getter methods #35

Merged
merged 1 commit into from
Oct 10, 2022
Merged

added return types for getter methods #35

merged 1 commit into from
Oct 10, 2022

Conversation

nikbott
Copy link
Contributor

@nikbott nikbott commented Oct 9, 2022

Since the methods may not return the intended type, they're wrapped in an Optional. Although I think all methods should have explicit return types, that should be further analyzed.

Copy link
Contributor

@Kalebu Kalebu left a comment

Choose a reason for hiding this comment

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

Hi @nikbott

Is it this best practice when specifying return types than importing Optional from typing ?

from typing import Dict, Any, List, Optional

def my_method(self) -> Optional[Dict[Any, Any]]
  """
  My method does a lot
  """
  return {}

@nikbott
Copy link
Contributor Author

nikbott commented Oct 10, 2022

According to the library documentation, Optional is simply a wrapper for a Union[X, None], which can be written as X | None. So both syntaxes should be valid and equivalent, and a matter of preference.

@Kalebu
Copy link
Contributor

Kalebu commented Oct 10, 2022

According to the library documentation, Optional is simply a wrapper for a Union[X, None], which can be written as X | None. So both syntaxes should be valid and equivalent, and a matter of preference.

Cool, Thanks for the clarification and your contribution

Merging this

@Kalebu Kalebu merged commit c058f26 into Neurotech-HQ:main Oct 10, 2022
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