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

Add FullyQualifiedNameProvider #465

Merged
merged 1 commit into from
Mar 26, 2021
Merged

Add FullyQualifiedNameProvider #465

merged 1 commit into from
Mar 26, 2021

Conversation

zsol
Copy link
Member

@zsol zsol commented Mar 11, 2021

Summary

This new provider resolves names to their fully qualified versions, and is capable of dealing with relative imports, addressing the same issue as #461.

Closes #460, closes #282.
This PR depends on #464

Test Plan

Added unit tests.

@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 11, 2021
@zsol zsol force-pushed the fqnp branch 4 times, most recently from 4566c8c to 3dc6afe Compare March 12, 2021 10:08
Base automatically changed from name-provider to master March 12, 2021 10:13
@codecov-io
Copy link

codecov-io commented Mar 12, 2021

Codecov Report

Merging #465 (2f527c1) into master (0ee0831) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
+ Coverage   94.62%   94.65%   +0.02%     
==========================================
  Files         236      236              
  Lines       22800    22902     +102     
==========================================
+ Hits        21575    21677     +102     
  Misses       1225     1225              
Impacted Files Coverage Δ
libcst/metadata/full_repo_manager.py 97.05% <ø> (ø)
libcst/codemod/_codemod.py 93.87% <100.00%> (ø)
libcst/metadata/__init__.py 100.00% <100.00%> (ø)
libcst/metadata/name_provider.py 100.00% <100.00%> (ø)
libcst/metadata/scope_provider.py 96.53% <100.00%> (+0.05%) ⬆️
libcst/metadata/tests/test_name_provider.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 0ee0831...2f527c1. Read the comment docs.

Copy link
Contributor

@jimmylai jimmylai left a comment

Choose a reason for hiding this comment

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

libcst/metadata/name_provider.py Outdated Show resolved Hide resolved
).get(file_path, "")
},
)
return set().union(*wrapper.resolve(FullyQualifiedNameProvider).values())
Copy link
Contributor

Choose a reason for hiding this comment

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

To make it simpler.

Suggested change
return set().union(*wrapper.resolve(FullyQualifiedNameProvider).values())
return set(wrapper.resolve(FullyQualifiedNameProvider).values())

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what I started with but unfortunately

TypeError: unhashable type: 'set'

Copy link
Contributor

Choose a reason for hiding this comment

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

>>> a = [[1, 2, 3], [4, 5, 6]]
>>> set(itertools.chain(*a))
{1, 2, 3, 4, 5, 6}
>>> set(y for x in a for y in x)
{1, 2, 3, 4, 5, 6}

libcst/metadata/tests/test_name_provider.py Outdated Show resolved Hide resolved
libcst/metadata/name_provider.py Outdated Show resolved Hide resolved
@zsol zsol force-pushed the fqnp branch 3 times, most recently from ea442b4 to 09d9cef Compare March 24, 2021 10:02
@zsol zsol requested a review from jimmylai March 24, 2021 10:08
@zsol
Copy link
Member Author

zsol commented Mar 24, 2021

I've updated the PR with changes :)

Copy link
Contributor

@jimmylai jimmylai left a comment

Choose a reason for hiding this comment

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

Something wrong in the doc. The FullyQualifiedNameProvider docstring wasn't found in the generated doc and FullyQualifiedNameProvider is not clickable.
https://9659-200896124-gh.circle-artifacts.com/0/doc/metadata.html
Please double check.

Otherwise, looks good.

@zsol
Copy link
Member Author

zsol commented Mar 24, 2021

Will do tomorrow

@zsol zsol merged commit 1bd1c08 into master Mar 26, 2021
@zsol zsol deleted the fqnp branch March 26, 2021 17:16
@zsol zsol mentioned this pull request Mar 29, 2021
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
5 participants