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

Turn AnnifException into an abstract base class and fix message prefix behavior #320

Merged
merged 3 commits into from
Aug 27, 2019

Conversation

osma
Copy link
Member

@osma osma commented Aug 26, 2019

I realized that AnnifException isn't intended to be instantiated directly but doing so was still possible. This PR changes into an abstract base class, which cannot be instantiated.

While performing the change, I noticed that the prefix mechanism used to generate error messages was broken. This PR fixes it as well.

Example error before the changes:

Error: Project 'noanalyzer': vocab setting is missing

Example error after the changes:

Error: Misconfigured project 'noanalyzer': vocab setting is missing

@osma osma added this to the 0.42 milestone Aug 26, 2019
@codecov
Copy link

codecov bot commented Aug 26, 2019

Codecov Report

Merging #320 into master will increase coverage by 0.06%.
The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #320      +/-   ##
==========================================
+ Coverage   99.38%   99.45%   +0.06%     
==========================================
  Files          55       55              
  Lines        2920     2917       -3     
==========================================
- Hits         2902     2901       -1     
+ Misses         18       16       -2
Impacted Files Coverage Δ
annif/exception.py 95.23% <80%> (+7.73%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b660eed...475bba0. Read the comment docs.

@osma
Copy link
Member Author

osma commented Aug 26, 2019

The abstractness isn't actually working though. It's still possible to instantiate AnnifException when defined this way. Apparently inheriting from ClickException somehow cancels the abstractness of the class...

@osma
Copy link
Member Author

osma commented Aug 26, 2019

Something weird is happening here, I posted a question on StackOverflow because I can't understand it.

@juhoinkinen
Copy link
Member

This SO discussion seems to be related.

@osma
Copy link
Member Author

osma commented Aug 27, 2019

Thanks @juhoinkinen , I wonder why I didn't find that discussion myself.

I answered my own SO question and will update this PR according to the workarounds provided in the earlier SO posts.

…ce Exception subclasses cannot be made abstract using the abc module.
@osma osma marked this pull request as ready for review August 27, 2019 07:07
@osma
Copy link
Member Author

osma commented Aug 27, 2019

Almost forgot to add the tests I wrote.

@osma osma requested a review from juhoinkinen August 27, 2019 07:21
@osma osma merged commit eaf0467 into master Aug 27, 2019
@osma osma deleted the annifexception-abstract-base-class branch September 30, 2019 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants