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

Update expand_source_files( ) #36

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

ritwik12
Copy link

Solves #35 as requested in 111, Allow files with all extensions irrespective of ".py"

Allow files with all extensions irrespective of ".py"
importlab/utils.py Outdated Show resolved Hide resolved
importlab/utils.py Outdated Show resolved Hide resolved
@rchen152
Copy link
Contributor

By the way, the changes in this PR probably shouldn't be released to PyPI until google/pytype#204 has been released (or we should update pytype's setup.py to pin to the current version of importlab), since I think it would cause pytype's unreadable input checking to complain about all sorts of non-Python files.

@martindemello
Copy link
Contributor

also, could you add some tests for your change? the best place would be in tests/graph.py; you can look at these two tests for how to do it:

https://github.com/google/importlab/blob/master/tests/test_graph.py#L145

@ritwik12
Copy link
Author

@martindemello Sure, I'll add test cases.

@ritwik12
Copy link
Author

@martindemello WIll removing test_unreadable_direct_source and test_unreadable_direct_source work? or We need to write one more function for test_readable?
I am not able to understand few things in the tests.

@martindemello
Copy link
Contributor

@ritwik12 the existing tests should not be broken by this change; you will need to add another test or two to test that we handle both readable and unreadable files without a .py extension.

the tests work by setting up a virtual file system as a dict of

# Deps = { file : ([resolved deps], [broken deps], {dep_file:provenance}) }

(look at SIMPLE_DEPS for instance, and see if you can make out what each entry in there is doing; please do ask questions if something is hard to follow because we would like the tests to be readable)

you will need to add a new dict, e.g. NON_PY_FILES, which copies SIMPLE_DEPS and adds another couple of entries for files with no extension, one with deps and one without deps. Then, when constructing a FakeImportGraph in the test, you pass it a set of unreadable files, so you can mark the file without deps as unreadable, and see that it gets handled correctly.

@ritwik12
Copy link
Author

@martindemello Thanks for your explaination

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants