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

Fix ModuleNotFoundError error when IPython is not installed #1247

Merged
merged 4 commits into from
May 7, 2021

Conversation

seisman
Copy link
Member

@seisman seisman commented Apr 27, 2021

Description of proposed changes

Fixes #1241.

A test is needed but currently I have no idea how to test it.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@seisman seisman added this to the 0.4.0 milestone Apr 27, 2021
@seisman seisman added bug Something isn't working skip-changelog Skip adding Pull Request to changelog labels Apr 27, 2021
@weiji14
Copy link
Member

weiji14 commented Apr 27, 2021

A test is needed but currently I have no idea how to test it.

Maybe follow the style of 329e480 to only install IPython on the Python3.9/NumPy1.20 tests, but not on the Python 3.7/NumPy1.17 tests?

@seisman
Copy link
Member Author

seisman commented Apr 27, 2021

A test is needed but currently I have no idea how to test it.

Maybe follow the style of 329e480 to only install IPython on the Python3.9/NumPy1.20 tests, but not on the Python 3.7/NumPy1.17 tests?

Good suggestion. Done in db36410 using the ${{ matrix.optional-packages }} variable.

@@ -7,7 +7,7 @@

try:
import IPython
except KeyError:
except ModuleNotFoundError:
IPython = None # pylint: disable=invalid-name
Copy link
Member

Choose a reason for hiding this comment

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

I can't see any reporting on Codecov (because the codecov upload doesn't work with test failures due to #1217), but I'm assuming this line has code coverage?

@weiji14
Copy link
Member

weiji14 commented Apr 27, 2021

Ok, when IPython isn't installed, there are a few failures on the Python 3.7/NumPy 1.17 tests:

We can either do 1) Use something like pytest.importorskip or 2) Catch the pygmt.exceptions.GMTError for these tests

@seisman
Copy link
Member Author

seisman commented May 3, 2021

Ok, when IPython isn't installed, there are a few failures on the Python 3.7/NumPy 1.17 tests:

We can either do 1) Use something like pytest.importorskip or 2) Catch the pygmt.exceptions.GMTError for these tests

Neither is good for the inset test, which is added in the docstring as an example.

@seisman
Copy link
Member Author

seisman commented May 4, 2021

As mentioned in #1247 (comment), I'm not happy with either way. Currently, I prefer to only commit the fix (79f329b) and don't try to work on the test/coverage, so that people can still use PyGMT even IPython is not installed (Fix #1241).

@seisman seisman requested a review from weiji14 May 4, 2021 19:23
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

As mentioned in #1247 (comment), I'm not happy with either way. Currently, I prefer to only commit the fix (79f329b) and don't try to work on the test/coverage, so that people can still use PyGMT even IPython is not installed (Fix #1241).

Yep, sounds ok with me.

@weiji14 weiji14 changed the title Fix the exception when IPython is not installed Fix ModuleNotFoundError error when IPython is not installed May 7, 2021
@weiji14 weiji14 merged commit c795eeb into master May 7, 2021
@weiji14 weiji14 deleted the fix-ipython branch May 7, 2021 02:48
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
…appingTools#1247)

* Fix the exception when IPython is not installed
* Install IPython on the Python 3.9/NumPy 1.20 test build only
* Revert "Install IPython on the Python 3.9/NumPy 1.20 test build only"

This reverts commit db36410.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ModuleNotFoundError exception when IPython in not installed
2 participants