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

Draft: Enable parsing of extension-less files #154

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

JosiahOne
Copy link

It's somewhat common for python scripts to be stored on disk as if they were executables (i.e. with no extension).

However, the current is_pysource function and properties explicitly check for a few known python extensions which causing pydeps to fail on such scripts (due to a assert target.is_pysource call in DummyModule.

This PR proposes adding a condition to assume any extension-less file is in fact a python script. I've added a test case to verify the change.

@codecov-commenter
Copy link

codecov-commenter commented Aug 25, 2022

Codecov Report

Merging #154 (f159a1e) into master (72003a3) will decrease coverage by 0.08%.
The diff coverage is 40.00%.

@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
- Coverage   73.65%   73.57%   -0.09%     
==========================================
  Files          17       17              
  Lines        1435     1438       +3     
  Branches      302      304       +2     
==========================================
+ Hits         1057     1058       +1     
  Misses        299      299              
- Partials       79       81       +2     
Impacted Files Coverage Δ
pydeps/dummymodule.py 69.86% <25.00%> (-3.00%) ⬇️
pydeps/target.py 95.38% <100.00%> (ø)
pydeps/depgraph.py 75.35% <0.00%> (+0.35%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@JosiahOne
Copy link
Author

To try to address code coverage I consolidated what appeared (to me) to be redundant logic. target.py now uses the is_pysource() function from dummymodule.py.

@JosiahOne
Copy link
Author

JosiahOne commented Aug 29, 2022

Oof, I see my test is incorrect. I'm checking that for an empty set where I don't want to.

I tried to look at fixing that, but there are other issues (almost certainly this was the reason the old assertions existed for checking whether files ended with .py to begin with). ModuleFinder.run_script() is used under-the-hood to resolve imports, but this method seems to only support files ending with .py. Or at the very least, pydeps interaction with this function is failing on files not ending with .py even though the file content is identical. I'll look into this some more.

@JosiahOne JosiahOne changed the title Enable parsing of extension-less files Draft: Enable parsing of extension-less files Aug 29, 2022
@JosiahOne JosiahOne marked this pull request as draft September 18, 2024 02:03
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.

2 participants