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

Ignore mypy's missing import warning for requests #4011

Merged
merged 3 commits into from
Jun 9, 2021

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented Jun 9, 2021

Fixes #4009

@AnirudhDagar
Copy link
Contributor

LGTM! Thanks for the fix @datumbox

A quick question: Any specific reasons for ignoring the type check instead of installing the stubs?

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

I'm with @AnirudhDagar here: installing the stubs would make the mypy check more reliable. mypy is not a necessary evil that needs to be silenced whenever it turns up something. We opted to use it to catch bugs that are not covered by our tests.

@NicolasHug
Copy link
Member

We opted to use it to catch bugs that are not covered by our tests.

I'm curious, in the PRs that were making the code mypy compliant, did you catch actual bugs?

@datumbox
Copy link
Contributor Author

datumbox commented Jun 9, 2021

@pmeier @AnirudhDagar The master is currently failing and when this happens it's high priority to fix it. This PR is not about improving the code, it's about restoring the CI in green state. In situations like this, please avoid blocking such PRs unless you see a bug being introduced and opt for making any suggested improvements on subsequent PRs.

@pmeier
Copy link
Collaborator

pmeier commented Jun 9, 2021

We opted to use it to catch bugs that are not covered by our tests.

I'm curious, in the PRs that were making the code mypy compliant, did you catch actual bugs?

It has been a while, but I'm fairly certain that the answer was no. IMO that is a testament to good reviews.

While developing, I often find myself in a position where mypy complains about something and it turns out it is something I didn't think through before. Plus, being mypy compliant makes thorough testing a whole lot easier.

Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Let's get this merged to get CI green. We can always send a follow-up PR adding it to the stubs.

@datumbox datumbox merged commit ea6be12 into pytorch:master Jun 9, 2021
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Stamping, but even though I hate mypy, I agree with @pmeier on this one: it wouldn't hurt much to spend a bit more time to fix the root of the issue.

@pmeier
Copy link
Collaborator

pmeier commented Jun 9, 2021

@datumbox The fix for this is exactly the same number of lines: add mypy --install-types after

pip install --user --progress-bar off mypy

@AnirudhDagar
Copy link
Contributor

@datumbox did not mean to question or block you. Sorry for that. It is definitely important to get a master to green in such a case.

@NicolasHug
Copy link
Member

Thanks @pmeier for the feedback

It has been a while, but I'm fairly certain that the answer was no. IMO that is a testament to good reviews.

And to good tests I think

While developing, I often find myself in a position where mypy complains about something and it turns out it is something I didn't think through before.

Interesting. My own experience was that whatever mypy was flagging was forcing me to re-write the code into something that either doesn't make sense, or is less readable ^^

Plus, being mypy compliant makes thorough testing a whole lot easier.

I disagree with the test part from that talk because it's talking about input validation checks: we can't rely on types for that, because this would assume that our users also use mypy. For libraries such as torchvision, type annotation brings nothing to the table when it comes to input validation of user-facing utilities.

@datumbox
Copy link
Contributor Author

datumbox commented Jun 9, 2021

@pmeier I understand that the fix you have in mind might be trivial in this specific case but changes like this still need time to be tested. IMO restoring the CI in green state when it's a false positive is high priority and buys us time to do any further due diligence on improving the code and resolving the root cause. By restoring the CI, it will unblock contributors such as @AnirudhDagar who currently get the wrong signal.

Happy to review a PR that addresses the issue and improve the codebase.

@datumbox datumbox deleted the ci/fix_mypy_fail branch June 9, 2021 08:26
AnirudhDagar added a commit to AnirudhDagar/vision that referenced this pull request Jun 9, 2021
facebook-github-bot pushed a commit that referenced this pull request Jun 14, 2021
Reviewed By: fmassa

Differential Revision: D29097713

fbshipit-source-id: 861f48451c5e1bf38a05f233f6475803d49b3d85
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

python_type_check CI is broken: missing stubs for requests module
6 participants