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

prefer is_bearable to isinstance #485

Merged
merged 1 commit into from
Mar 10, 2024
Merged

Conversation

rtbs-dev
Copy link
Contributor

@rtbs-dev rtbs-dev commented Mar 4, 2024

Ran into an issue with parametrized generics not being supported by isinstance. Since you're already relying on beartype, I've found it much easier to strictly rely on is_bearable to do dispatch, rather than isinstance. Stuff just behaves like I expect it to.

Line 389 in se.py was raising a SerdeError: isinstance() argument 2 cannot be a parametrized generic.

For more on the DOOR API see here, with is_bearable specifically documented here As it mentions there, this is designed to replace isinstance by being a strict superset:

is_bearable() is a strict superset of the isinstance() builtin. is_bearable() can thus be safely called wherever isinstance() is called with the same exact parameters in the same exact order:

Copy link

codecov bot commented Mar 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.50%. Comparing base (f1c49f2) to head (fe769df).
Report is 17 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #485   +/-   ##
=======================================
  Coverage   89.49%   89.50%           
=======================================
  Files          12       12           
  Lines        1933     1934    +1     
  Branches      401      401           
=======================================
+ Hits         1730     1731    +1     
  Misses        148      148           
  Partials       55       55           

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

Copy link
Owner

@yukinarit yukinarit left a comment

Choose a reason for hiding this comment

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

LGTM

@yukinarit yukinarit added the bug Bug report or fix label Mar 10, 2024
@yukinarit yukinarit merged commit 6ddd4a2 into yukinarit:main Mar 10, 2024
9 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report or fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants