Skip to content

ENH Support type hinting using mypy#68

Merged
BorisMuzellec merged 28 commits intoscverse:mainfrom
illumination-k:feature/mypy
Feb 20, 2023
Merged

ENH Support type hinting using mypy#68
BorisMuzellec merged 28 commits intoscverse:mainfrom
illumination-k:feature/mypy

Conversation

@illumination-k
Copy link
Copy Markdown
Contributor

Reference Issue or PRs

Please see #39

What does your PR implement? Be specific.

This PR support type hinting by mypy and fixed some docstring which incompatible with mypy type checking.

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

Hi @illumination-k, thanks a lot for your work!

This is our first contribution from an external collaborator, we're very excited about it :).

I have just approved the CI to run on this PR. It seems that some checks have failed, could you have a look at it if you have time?

FYI I'll be away next week so your interlocutor will probably be @maikia.

Thanks again for your help, hope to merge this soon!

@BorisMuzellec BorisMuzellec requested a review from maikia February 2, 2023 09:02
@illumination-k
Copy link
Copy Markdown
Contributor Author

Sorry for failing CI. I ran CI and pre-commit scripts manually and maybe OK. If failed, I will check tomorrow.

@maikia
Copy link
Copy Markdown
Collaborator

maikia commented Feb 6, 2023

Hi @illumination-k
Thanks for your contribution! I think accidentally you added docs/auto_examples (they are generated by sphinx when make html is run and should not be a part of git). Can you remove them and I will review your PR?

@illumination-k
Copy link
Copy Markdown
Contributor Author

illumination-k commented Feb 9, 2023

Sorry @maikia, I missed your comments. I removed auto_examples. Should we add them in .gitignore?

Copy link
Copy Markdown
Collaborator

@maikia maikia left a comment

Choose a reason for hiding this comment

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

@illumination-k thanks again for your contribution. Very nice and through PR.

Could you provide me with the details on your settings of mypy, or even better if you can add it to the CI (and I will reproduce the steps locally).
ATM if I run naive mypy it fails with errors, eg
image
To my knowledge those errors can also be coming from the version of Python. The one I am using locally (as well as the one used in our CI) is 3.8.

I also didn’t realise before but api/docstrings should also be removed from the PR, and yes, adding this as well as auto examples to .gitignore is a great idea. Feel free to open a new PR if you like.

@illumination-k
Copy link
Copy Markdown
Contributor Author

I used Python 3.10, and you are right python 3.8 dose not support direct list, tuple. Now I fixed type hinting for Python 3.8

@maikia maikia mentioned this pull request Feb 15, 2023
erge branch 'main' into feature/mypy
Copy link
Copy Markdown
Collaborator

@maikia maikia left a comment

Choose a reason for hiding this comment

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

@illumination-k thanks again for your PR! I extended it to have mypy running within CI and corrected a bug coming from one of the changes in the code. Can you please make sure that you agree with all the changes I did?

@BorisMuzellec @mandreux-owkin can one of you review before merge (as I committed to this PR I prefer that there is someone else checking if all is good, thx)

Copy link
Copy Markdown
Collaborator

@BorisMuzellec BorisMuzellec left a comment

Choose a reason for hiding this comment

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

LGTM, up to minor suggestions.

Thanks a lot @illumination-k (and @maikia) for the work!

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

BorisMuzellec commented Feb 16, 2023

Hi, now that the AnnData integration has been merged, there will be numerous merge conflicts to resolve. I'll handle them, if that's OK for you.

@illumination-k
Copy link
Copy Markdown
Contributor Author

Sure! Sorry for my late response, @BorisMuzellec .

@BorisMuzellec BorisMuzellec requested review from a user and maikia February 16, 2023 14:32
@illumination-k
Copy link
Copy Markdown
Contributor Author

illumination-k commented Feb 17, 2023

Your commit maybe inactivated type hinting. There are many Any types. I think that in order to fully benefit from type hints with mypy, you should use a command such as mypy . --check-untyped-defs --strict.

Would it be better to close this PR and create a new one, or create new commit in this PR?

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

Hi @illumination-k, indeed, thanks for checking!

It seems like I made some git manipulation mistakes, sorry for that...

I don't think it's necessary to close this PR. I'll just revert to where it was before I made changes and take it from there. We'll squash anyways at merge time.

Boris MUZELLEC added 3 commits February 17, 2023 10:03
Copy link
Copy Markdown
Collaborator

@maikia maikia left a comment

Choose a reason for hiding this comment

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

This PR did grow quite a bit. LGTM. just few minor comments.
@illumination-k can you also comment if you agree with all the changes done to your PR?

@maikia
Copy link
Copy Markdown
Collaborator

maikia commented Feb 17, 2023

@BorisMuzellec there are also some conflicts needing resolve

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

@BorisMuzellec there are also some conflicts needing resolve

Yes, I am currently handling those. These are due to the anndata merge

@illumination-k
Copy link
Copy Markdown
Contributor Author

I would prefer to address mypy . --check-untyped-def and ignore untyped things coming from anndata integration in this PR. Because there are many untyped things and it is pretty tough work. I'm not so familiar with anndata, but it seems not to support type stubs, so maybe some work is also need to handle anndata type.

We should address anndata typing and --strict flag in the next PRs.

@BorisMuzellec
Copy link
Copy Markdown
Collaborator

Hi @illumination-k and @maikia, I did my best to pass the the mypy . --check-untyped-defs (without the strict option).
Could you have a look?

I agree with @illumination-k that we should deal with more intricate typing issues brought by the anndata integration in a new PR.

@BorisMuzellec BorisMuzellec requested a review from maikia February 17, 2023 13:56
@maikia
Copy link
Copy Markdown
Collaborator

maikia commented Feb 17, 2023

@BorisMuzellec I left some comments in my previous review which were still not addressed. Otherwise I agree with your last comment

Co-authored-by: Maria Telenczuk <maja_ka@hotmail.com>
@BorisMuzellec BorisMuzellec changed the title Support type hinting by mypy ENH Support type hinting using mypy Feb 17, 2023
@BorisMuzellec
Copy link
Copy Markdown
Collaborator

BorisMuzellec commented Feb 20, 2023

@illumination-k and @maikia since all comments are now resolved, unless there is something else you would like to change I'll merge this PR today

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