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

Add user-friendly message when missing importer #1959

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

edoardob90
Copy link

Fixes #1486.

Add a clear error message if a user tries to import a non-jrnl file, since that's the only importer available right now.

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

Note: I had to make some changes in line with PR #1955 to have passing tests via tox. Everything's fine with pytest because of the pinned version of pytest-bdd==7.3.0.

@edoardob90
Copy link
Author

A collateral comment about an implementation detail I came across with this fix: the jrnl.messages.MsgText class cannot be sub-classed. I could see an advantage of adjusting it when one wants to add custom messages for a new importer, for example.

This change would be rather straightforward:

  • Create a MsgTextBase(Enum)
  • Have MsgText inherits from it
  • Adjust the __init__.py imports
  • Optional: fix the problems with typing related to the messages package

Instead of

from jrnl.messages import Message
# and similar lines

do

from typing import TypeAlias

from jrnl.messages import Message as _Message
# other imports

Message: TypeAlias = _Message.Message
# other lines

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.

--format list and error output is incorrect for importing
1 participant