Skip to content

remove type_hint_tests and convert the files to use the new test style#53167

Closed
guilhermeleobas wants to merge 18 commits intopytorch:masterfrom
guilhermeleobas:type_hint_tests
Closed

remove type_hint_tests and convert the files to use the new test style#53167
guilhermeleobas wants to merge 18 commits intopytorch:masterfrom
guilhermeleobas:type_hint_tests

Conversation

@guilhermeleobas
Copy link
Copy Markdown
Collaborator

This is a follow-up PR of #52408 and move/convert all files under test/type_hint_tests/*.py to use the new test style.

@guilhermeleobas guilhermeleobas added the module: typing Related to mypy type annotations label Mar 3, 2021
@guilhermeleobas guilhermeleobas requested a review from rgommers March 3, 2021 03:20
@guilhermeleobas guilhermeleobas self-assigned this Mar 3, 2021
@facebook-github-bot
Copy link
Copy Markdown
Contributor

facebook-github-bot commented Mar 3, 2021

💊 CI failures summary and remediations

As of commit ba7650c (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


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.

@guilhermeleobas guilhermeleobas changed the title Get rid of type_hint_tests and convert the files to use the new test style remove type_hint_tests and convert the files to use the new test style Mar 3, 2021
@guilhermeleobas guilhermeleobas marked this pull request as draft March 3, 2021 04:50
@guilhermeleobas guilhermeleobas removed the request for review from rgommers March 3, 2021 04:50
@rgommers
Copy link
Copy Markdown
Collaborator

rgommers commented Mar 6, 2021

Overall looks good, thanks @guilhermeleobas. The renamed test/typing/reveal/torch_cuda_random.py doesn't contain any expected values. It looks like that file can simply be deleted?

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 15, 2021

Codecov Report

Merging #53167 (ba7650c) into master (8734e88) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #53167   +/-   ##
=======================================
  Coverage   77.34%   77.34%           
=======================================
  Files        1887     1887           
  Lines      184826   184826           
=======================================
+ Hits       142954   142959    +5     
+ Misses      41872    41867    -5     

@guilhermeleobas guilhermeleobas marked this pull request as ready for review March 16, 2021 04:10
@guilhermeleobas
Copy link
Copy Markdown
Collaborator Author

guilhermeleobas commented Mar 16, 2021

Hi @rgommers, done! I've deleted test/typing/reveal/torch_cuda_random.py

@jbschlosser jbschlosser added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Mar 16, 2021
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@walterddr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Comment thread mypy.ini
files =
torch,
caffe2,
test/type_hint_tests,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I'm missing some context; why is this line being removed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That whole directory is being removed. All the files in it test very little, and we now have a much better way of testing with the "reveal" style tests under test/typing/.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah ok thanks! Followup question: how does this relate to #50513? Like I see that now we have two different test files (test/test_type_hints.py and test/test_typing.py) that both run mypy

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Those two files do different things: the first one just runs mypy over the whole code base, the second one has specific unit tests for individual annotations. I'm not sure I see a compelling reason to want to run them in a single command. It's possible of course, but mypy is just a tool and type annotations are just one code aspect - we also don't say we want to run (e.g.) all autograd tests in a single command. There's just tests scattered in places.

The one thing that would be good is better mypy cache reuse. Right now test_type_hints.py can generate caches in the repo root and in test/, and test_typing.py in test/typing/. It'd be nice if all caches for the same .ini file ended up only in the repo root.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense :) Regarding cache reuse, though, would that necessarily be better if they all shared the same cache dir? It seems like that might provide opportunity for additional unnecessary cache invalidation, since the commands being invoked are somewhat different from each other.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

True, I'm not quite sure if it would be better. As long as the regression tests only take 10 seconds or so (which is the case now), it's not even worth optimizing I think.

Copy link
Copy Markdown
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

lgtm. any additional comments?

@facebook-github-bot
Copy link
Copy Markdown
Contributor

@walterddr merged this pull request in bbb06c0.

laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
pytorch#53167)

Summary:
This is a follow-up PR of pytorch#52408 and move/convert all files under `test/type_hint_tests/*.py` to use the new test style.

Pull Request resolved: pytorch#53167

Reviewed By: ejguan

Differential Revision: D27081041

Pulled By: walterddr

fbshipit-source-id: 56508083800a5e12a7af88d095ca26229f0df358
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: typing Related to mypy type annotations open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants