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 some types hints. #856

Merged
merged 5 commits into from
Jan 20, 2020
Merged

Adding some types hints. #856

merged 5 commits into from
Jan 20, 2020

Conversation

gabrieldemarmiesse
Copy link
Contributor

@gabrieldemarmiesse gabrieldemarmiesse commented Dec 15, 2019

See the PR keras-team/keras-tuner#163 . If we don't need to support python 2, this should be fine to do it. The types are already displayed in the function signature in the docs, but I plan to also add them in the text description automatically with keras-autodoc. Here is what it looks like right now:
docs_autokeras

@haifeng-jin
Copy link
Collaborator

Codacy Here is an overview of what got changed by this pull request:

Issues
======
- Added 1
           

See the complete overview on Codacy

@gabrieldemarmiesse
Copy link
Contributor Author

@haifeng-jin I believe that adding type hints is a safe move. It doesn't have any runtime consequences. From the pep:

While these annotations are available at runtime through the usual __annotations__ attribute, no type checking happens at runtime.

Adding some tool on top of it might. But this PR is focused only on type hints.

I believe it is safe to merge an doesn't necessitate a review from @fchollet or @omalleyt12 .

@haifeng-jin
Copy link
Collaborator

@gabrieldemarmiesse
I think it is a good idea to do so if it can save the manual type check and error raising process.
However, since I am really not familiar with this mechanism there might be some cons we are not aware of. Adding it to all APIs would have some workload.
I would rather wait for the reviews from @fchollet and @omalleyt12 before we proceed.
Thank you for your patience.

@gabrieldemarmiesse
Copy link
Contributor Author

Ok, it doesn't hurt to have another opinion :)

@gabrieldemarmiesse
Copy link
Contributor Author

Also if we decide to type the API surface and do runtime type checks, I'd be happy to implement it :)

autokeras/task.py Outdated Show resolved Hide resolved
@fchollet
Copy link
Member

However, since I am really not familiar with this mechanism there might be some cons we are not aware of.

What are some potential issues?

@haifeng-jin
Copy link
Collaborator

However, since I am really not familiar with this mechanism there might be some cons we are not aware of.

What are some potential issues?

I don't know.
If you don't see any potential issue, then we can just do it.

Copy link
Collaborator

@haifeng-jin haifeng-jin left a comment

Choose a reason for hiding this comment

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

I am merging it. It would be great if you can continue to work on adding type hints to other classes in task.py and auto_model.py. Thank you! @gabrieldemarmiesse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants