Skip to content

fix: handle UnionType in validate_type error message#343

Open
williambdean wants to merge 2 commits into
mainfrom
fix/341-uniontype-name-error
Open

fix: handle UnionType in validate_type error message#343
williambdean wants to merge 2 commits into
mainfrom
fix/341-uniontype-name-error

Conversation

@williambdean

Copy link
Copy Markdown
Owner

Closes #341

The validate_type decorator crashed with AttributeError when formatting
error messages for functions annotated with union types (e.g.,
NormalInverseGamma | NormalGamma) since types.UnionType has no name.

Now uses str() for UnionType instances and name for regular types.

The validate_type decorator crashed with AttributeError when formatting
error messages for functions annotated with union types (e.g.,
NormalInverseGamma | NormalGamma) since types.UnionType has no __name__.

Now uses str() for UnionType instances and __name__ for regular types.
@codecov

codecov Bot commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.04%. Comparing base (47d536c) to head (9cc0c30).
⚠️ Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #343      +/-   ##
==========================================
+ Coverage   94.02%   94.04%   +0.01%     
==========================================
  Files          10       10              
  Lines        1323     1327       +4     
==========================================
+ Hits         1244     1248       +4     
  Misses         79       79              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Regenerated with matplotlib 3.11 to match CI rendering environment.
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.

AttributeError: 'types.UnionType' object has no attribute '__name__'

1 participant