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

Improve error message when representing incompatible value for Union #1103

Merged
merged 2 commits into from
May 19, 2020

Conversation

kitchoi
Copy link
Contributor

@kitchoi kitchoi commented May 19, 2020

If I try to create a trait type like this:

Union(Dict(), "none")

I get an error message:

Union trait declaration expects a trait type or an instance of trait type or None, but got none instead

This PR improves the error message so that it reads:

Union trait declaration expects a trait type or an instance of trait type or None, but got 'none' instead

which is much clearer about what went wrong.

Checklist

  • Tests
  • Update API reference (docs/source/traits_api_reference)
  • Update User manual (docs/source/traits_user_manual)
  • Update type annotation hints in traits-stubs

@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #1103 into master will decrease coverage by 1.94%.
The diff coverage is 68.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1103      +/-   ##
==========================================
- Coverage   76.15%   74.21%   -1.95%     
==========================================
  Files          54       78      +24     
  Lines        6493     8469    +1976     
  Branches     1263     1610     +347     
==========================================
+ Hits         4945     6285    +1340     
- Misses       1205     1806     +601     
- Partials      343      378      +35     
Impacted Files Coverage Δ
traits/api.py 100.00% <ø> (+9.67%) ⬆️
traits/base_trait_handler.py 61.76% <ø> (ø)
traits/observers/_i_notifier.py 0.00% <0.00%> (ø)
traits/observers/events.py 0.00% <0.00%> (ø)
traits/traits.py 75.10% <ø> (-2.45%) ⬇️
traits/util/resource.py 15.25% <ø> (ø)
traits/observers/_generated_parser.py 51.96% <51.96%> (ø)
traits/trait_types.py 72.29% <80.00%> (-0.16%) ⬇️
traits/observers/parsing.py 95.34% <95.34%> (ø)
traits/observers/_trait_event_notifier.py 96.61% <96.61%> (ø)
... and 57 more

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 486a289...1445f04. Read the comment docs.

Copy link
Member

@mdickinson mdickinson left a comment

Choose a reason for hiding this comment

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

LGTM

@kitchoi kitchoi merged commit f7abb73 into master May 19, 2020
@kitchoi kitchoi deleted the union-error-message-repr branch May 19, 2020 09:31
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.

3 participants