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

Raise ModuleNotPresent instead of KeyError from find_modules_that_directly_import #113

Open
pydanny opened this issue Jun 9, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@pydanny
Copy link

pydanny commented Jun 9, 2023

To produce the error:

import grimp
graph = grimp.build_graph("nifty_library", include_external_packages=True)
graph.find_modules_that_directly_import('yaml')

This results in this error:

----> 1 graph.find_modules_that_directly_import('yaml')

File ~/.virtualenvs/kraken-core/lib/python3.10/site-packages/grimp/adaptors/graph.py:234, in ImportGraph.find_modules_that_directly_import(self, module)
    233 def find_modules_that_directly_import(self, module: str) -> Set[str]:
--> 234     return self._importers_by_imported[module]

KeyError: 'yaml'
@pydanny pydanny changed the title Searching on 'yaml' generates a KeyError Search on 'yaml' generates a KeyError Jun 9, 2023
@seddonym seddonym changed the title Search on 'yaml' generates a KeyError Raise ModuleNotPresent instead of KeyError from find_modules_that_directly_import Jun 12, 2023
@seddonym
Copy link
Owner

Thanks for the bug report, yes I agree we could do better here. I think we should raise grimp.exceptions.ModuleNotPresent in this case, which is already raised from some other methods under similar circumstances.

@seddonym seddonym added the good first issue Good for newcomers label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants