Fixit icon indicating copy to clipboard operation
Fixit copied to clipboard

[bug] CollapseIsinstanceChecksRule rewrite elif as if wrongly

Open jimmylai opened this issue 5 years ago • 3 comments

Summary

This is for reproducing a bug of CollapseIsinstanceChecksRule. It rewrites elif as if which is wrong.

CC @isidentical

Test Plan

tox -e py37 fixit.tests.CollapseIsinstanceChecksRule

Output:

F....................
======================================================================
FAIL: test_INVALID_0 (fixit.common.testing.CollapseIsinstanceChecksRule)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 221, in test_method
    return getattr(self, custom_test_method_name)(data, rule, fixture_file)
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 117, in _test_method
    validate_patch(report, test_case)
  File "/Users/jimmylai/github/Fixit/fixit/common/testing.py", line 48, in validate_patch
    + f"But found:\n{patched_code}"
AssertionError: Auto-fix did not produce expected result.
Expected:
if something:
    pass
elif isinstance(x, (y, z)):
    pass

But found:
if something:
    pass
if isinstance(x, (y, z)):
    pass


----------------------------------------------------------------------
Ran 21 tests in 0.400s

jimmylai avatar Sep 15 '20 06:09 jimmylai

Guess, this is not 'acutally' relevant with CollapseIsinstanceChecksRule, or any other rule. Every time a node replaced with a newly created node, this happens (as far as I can observe);

if something: pass
elif (
    'test'
    'foo'
): pass

isidentical avatar Sep 16 '20 17:09 isidentical

Hi @jimmylai!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

facebook-github-bot avatar May 26 '21 07:05 facebook-github-bot

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

facebook-github-bot avatar Oct 12 '21 23:10 facebook-github-bot

Hey there! We appreciate your contributions, but we're in the process of making some large changes to the core of Fixit. We will try to have more info about the direction we're heading soon, but in the mean time, we are closing all outstanding PR's from before we started this work. Thank you for your understanding.

amyreese avatar Oct 07 '22 01:10 amyreese