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

fix(compare_singleton_primitives_by_is): compare Name directly instead of QualifiedName #391

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

llllvvuu
Copy link
Contributor

@llllvvuu llllvvuu commented Sep 7, 2023

Summary

fixes #378 and #375 which are caused by Instagram/LibCST#389.

Qualifying a name will never make something that wasn't already True/False/None into a True/False/None, so it's not necessary.

Test Plan

Added two Valid cases, one of which breaks on HEAD^.

@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 Sep 7, 2023
…d of QualifiedName

fixes Instagram#378 and Instagram#375 which are caused by Instagram/LibCST#389.

Qualifying a name will never make some thing that wasn't already
True/False/None into a True/False/None:

```python
import libcst as cst
from libcst.metadata.name_provider import QualifiedNameProvider
from textwrap import dedent

wrapper = cst.MetadataWrapper(
    cst.parse_module(dedent(
    '''
        x = None
        x()
    '''
    ))
)
x_ref = wrapper.module.body[1].body[0].value
print(wrapper.resolve(QualifiedNameProvider)[x_ref]())
```
prints:
```python
{QualifiedName(name='x', source=<QualifiedNameSource.LOCAL: 3>)}
```

Co-authored-by: Amethyst Reese <[email protected]>
@amyreese amyreese merged commit 79d2080 into Instagram:main Oct 17, 2023
13 checks passed
@amyreese
Copy link
Member

Thank you!

I modified the fix slightly, so that it still checks for cst.Name, but also still uses the existing set of QualifiedName values.

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.

Incorrect suggestion to fix string comparison
3 participants