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

[AddImportsVisitor] generate deterministic add import output by sorting the sets. #274

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

jimmylai
Copy link
Contributor

@jimmylai jimmylai commented Mar 25, 2020

Summary

@pradeep90 reported that AddImportsVisitor generates the added import alias in random order which make codemod unit test failed randomly.

In the example code like this, the order of Any, Dict, List is not deterministic.

                """
                from typing import Any, Dict, List
                from typing import Any, List
                def foo() -> List[Any]: ...
                def goo() -> Dict[Any, Any]: ...
                """,
                """
                from typing import Any
                def foo():
                    return []
                def goo():
                    return {}
                """,
                """
                from typing import Any, Dict, List
                def foo() -> List[Any]:
                    return []
                def goo() -> Dict[Any, Any]:
                    return {}
                """,

Test Plan

Add new test case.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 25, 2020
@codecov-io
Copy link

codecov-io commented Mar 25, 2020

Codecov Report

Merging #274 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #274   +/-   ##
=======================================
  Coverage   93.95%   93.96%           
=======================================
  Files         219      219           
  Lines       21241    21245    +4     
=======================================
+ Hits        19958    19962    +4     
  Misses       1283     1283           
Impacted Files Coverage Δ
libcst/codemod/visitors/_add_imports.py 95.23% <ø> (ø)
libcst/codemod/visitors/tests/test_add_imports.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1b9a52b...d1e4712. Read the comment docs.

@jimmylai jimmylai merged commit 0dc3995 into Instagram:master Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants