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

fix: injecting None into takes optional #106

Merged
merged 6 commits into from
Mar 18, 2024

Conversation

tlambert03
Copy link
Member

@tlambert03 tlambert03 commented Mar 18, 2024

fixes a bug where injecting into a function that takes an Thing | None but doesn't include a default of None raise an exception if the provider returns None

import in_n_out as ino

store = ino.Store(name="store")


class Thing: ...


@store.register_provider
def get_thing() -> Thing | None:
    return None


@store.inject
def use_thing(thing: Thing | None) -> None:
    print(f"got {thing=}")


use_thing()

Copy link

codspeed-hq bot commented Mar 18, 2024

CodSpeed Performance Report

Merging #106 will not alter performance

Comparing tlambert03:fix-optional (a24764d) with main (27a3f9e)

Summary

✅ 5 untouched benchmarks

@tlambert03 tlambert03 changed the title fix: injecting into takes optional fix: injecting None into takes optional Mar 18, 2024
Copy link

codecov bot commented Mar 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (78390f6) to head (a24764d).
Report is 27 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #106   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            5         5           
  Lines          521       523    +2     
=========================================
+ Hits           521       523    +2     

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

@tlambert03 tlambert03 merged commit bc485a6 into pyapp-kit:main Mar 18, 2024
22 of 23 checks passed
@tlambert03 tlambert03 deleted the fix-optional branch March 18, 2024 16:02
@tlambert03 tlambert03 added the bug Something isn't working label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant