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

Remove use of deprecated imp module in job system. #1717

Merged
merged 2 commits into from Jun 11, 2022

Conversation

mblayman
Copy link
Contributor

@mblayman mblayman commented Apr 9, 2022

Hello, django-extensions devs! Thanks for a great package. I use django-extensions all the time.

This PR removes the following Python deprecation:

venv/lib/python3.9/site-packages/django_extensions/management/jobs.py:4
  /Users/matt/projects/homeschool/venv/lib/python3.9/site-packages/django_extensions/management/jobs.py:4: 
  DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation
  for alternative uses
    from imp import find_module

Since Python 3.3, import_module imports the parent modules. I believe this mimics the behavior of the existing code that is using find_module. https://docs.python.org/3/library/importlib.html#importlib.import_module

import_module will also raise an ImportError if the module name is not found. This matches the expected error interface of find_job_module.

I took the liberty of adding a type annotation and docstring while I was at it.

I did not write any additional tests because this portion of the code has decent test coverage, and I saw that the existing tests cover find_job_module.

@camilonova camilonova merged commit 3879e4b into django-extensions:main Jun 11, 2022
@mblayman mblayman deleted the rm-imp-find-module branch June 11, 2022 16:37
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.

None yet

3 participants