Move mypy wrapper to tools#54268
Move mypy wrapper to tools#54268samestep wants to merge 5 commits intopytorch:masterfrom samestep:move-mypy-wrapper-to-tools
Conversation
💊 CI failures summary and remediationsAs of commit 61c5dc9 (more details on the Dr. CI page):
This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions to the (internal) Dr. CI Users group. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
janeyx99
left a comment
There was a problem hiding this comment.
Looks good once you fix flake8
.github/workflows/test_tools.yml
Outdated
| run: | | ||
| set -eux | ||
| pip install -r requirements.txt | ||
| pip install mypy==0.770 |
There was a problem hiding this comment.
I think we discussed this before, but why did we decide against having mypy be a requirement?
There was a problem hiding this comment.
I don't remember; @pytorch/pytorch-dev-infra anyone know?
facebook-github-bot
left a comment
There was a problem hiding this comment.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
@samestep has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: #54268 removed `test_run_mypy` since now we're running `mypy` as its own job in GitHub Actions, but previously we used this `set_cwd` context manager in that test to ensure that we picked up the `mypy` config correctly. However, for some reason, we have not been doing that in `test_doc_examples`, which has been succeeding in CI for a while despite being broken. Specifically, [`run_test.py` changes the working directory to `test/` before running test files](https://github.com/pytorch/pytorch/blob/48aaea3359cffe7982ce24b8742c7a1f4b456a92/test/run_test.py#L534-L535), which is contrary to [what `CONTRIBUTING.md` instructs developers to do](https://github.com/pytorch/pytorch/blob/48aaea3359cffe7982ce24b8742c7a1f4b456a92/CONTRIBUTING.md#python-unit-testing). As a result, in CI, `test/test_type_hints.py` has been passing in CI, but if you run it locally from the root of the repo, this you get this error: ``` F ====================================================================== FAIL: test_doc_examples (__main__.TestTypeHints) Run documentation examples through mypy. ---------------------------------------------------------------------- Traceback (most recent call last): File "test/test_type_hints.py", line 127, in test_doc_examples self.fail(f"mypy failed:\n{stdout}") AssertionError: mypy failed: test/generated_type_hints_smoketest.py:851: error: Name 'tensor' is not defined [name-defined] test/generated_type_hints_smoketest.py:853: error: Name 'tensor' is not defined [name-defined] Found 2 errors in 1 file (checked 1 source file) ---------------------------------------------------------------------- Ran 1 test in 1.416s FAILED (failures=1) ``` Pull Request resolved: #56388 Test Plan: Before this PR, the first of the following two commands should fail (since that is essentially what is run in CI), but the second should fail: ``` python test/run_test.py -i test_type_hints python test/test_type_hints.py ``` After this PR, both commands should succeed. Reviewed By: driazati Differential Revision: D27860173 Pulled By: samestep fbshipit-source-id: efb82fffd7ccb04d0331824b40bdef7bbc319c98
Summary: pytorch#54268 removed `test_run_mypy` since now we're running `mypy` as its own job in GitHub Actions, but previously we used this `set_cwd` context manager in that test to ensure that we picked up the `mypy` config correctly. However, for some reason, we have not been doing that in `test_doc_examples`, which has been succeeding in CI for a while despite being broken. Specifically, [`run_test.py` changes the working directory to `test/` before running test files](https://github.com/pytorch/pytorch/blob/48aaea3359cffe7982ce24b8742c7a1f4b456a92/test/run_test.py#L534-L535), which is contrary to [what `CONTRIBUTING.md` instructs developers to do](https://github.com/pytorch/pytorch/blob/48aaea3359cffe7982ce24b8742c7a1f4b456a92/CONTRIBUTING.md#python-unit-testing). As a result, in CI, `test/test_type_hints.py` has been passing in CI, but if you run it locally from the root of the repo, this you get this error: ``` F ====================================================================== FAIL: test_doc_examples (__main__.TestTypeHints) Run documentation examples through mypy. ---------------------------------------------------------------------- Traceback (most recent call last): File "test/test_type_hints.py", line 127, in test_doc_examples self.fail(f"mypy failed:\n{stdout}") AssertionError: mypy failed: test/generated_type_hints_smoketest.py:851: error: Name 'tensor' is not defined [name-defined] test/generated_type_hints_smoketest.py:853: error: Name 'tensor' is not defined [name-defined] Found 2 errors in 1 file (checked 1 source file) ---------------------------------------------------------------------- Ran 1 test in 1.416s FAILED (failures=1) ``` Pull Request resolved: pytorch#56388 Test Plan: Before this PR, the first of the following two commands should fail (since that is essentially what is run in CI), but the second should fail: ``` python test/run_test.py -i test_type_hints python test/test_type_hints.py ``` After this PR, both commands should succeed. Reviewed By: driazati Differential Revision: D27860173 Pulled By: samestep fbshipit-source-id: efb82fffd7ccb04d0331824b40bdef7bbc319c98
This PR
torch/testing/_internal/mypy_wrapper.py(and its accompanying tests fromtest/test_testing.py) totools,test_run_mypyfromtest/test_type_hints.py, andmypyconfigs (previously duplicated acrossmypy_wrapper.pyand.github/workflows/lint.yml) with a simpler globTest plan:
Should also be run in the "Test tools" GHA workflow in CI: