Skip to content

Fix ModuleNotFoundError error when IPython is not installed - #1247

Merged
weiji14 merged 4 commits into
masterfrom
fix-ipython
May 7, 2021
Merged

Fix ModuleNotFoundError error when IPython is not installed#1247
weiji14 merged 4 commits into
masterfrom
fix-ipython

Conversation

@seisman

@seismanseisman commented Apr 27, 2021

Copy link
Copy Markdown
Member

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

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

Copy link
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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.

Comment threadpygmt/figure.py
import IPython
except KeyError:
except ModuleNotFoundError:
IPython = None # pylint: disable=invalid-name

Copy link
Copy Markdown
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
Copy Markdown
Member

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
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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 weiji14May 4, 2021 19:23

@weiji14weiji14 left a comment

Copy link
Copy Markdown
Member

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.

@weiji14weiji14 changed the title Fix the exception when IPython is not installedFix ModuleNotFoundError error when IPython is not installedMay 7, 2021
@weiji14
weiji14 merged commit c795eeb into masterMay 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't workingskip-changelogSkip 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

@seisman@weiji14