Add type annotations for punq#226
Conversation
Codecov Report❌ Patch coverage is
❌ Your project check has failed because the head coverage (82.0%) is below the target coverage (90.0%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
=========================================
- Coverage 100.0% 82.0% -18.0%
=========================================
Files 2 1 -1
Lines 205 201 -4
Branches 25 28 +3
=========================================
- Hits 205 165 -40
- Misses 0 24 +24
- Partials 0 12 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@bobthemighty I am leaving failing coverage checks, because I am pretty sure that it is not correct. I've double checked that running tests and adding exceptions to the "uncoverred" lines actually fail tests: So, I consider this ready for review. |
bobthemighty
left a comment
There was a problem hiding this comment.
Happy to approve if this works for type checks and subtyping. Can we add a block at the bottom of the test container module
if typing.TYPE_CHECKING:
foo : Impl = container.resovle(...)
for a bunch of examples? Looks pretty good to me. Maybe I was just struggling with 3.8/3.9?
|
|
||
| assert_type(container.resolve(Service), Service) | ||
| assert_type(container.resolve("string"), Any) | ||
| assert_type(container.resolve(Impl, arg=1, other=2), Impl) |
There was a problem hiding this comment.
These all look concrete to me, how does this work with subtyping?
container.register(MessageWriter, StdoutMessageWriter)
assert_type(container.resolve(MessageWriter, MessageWriter)
Also, I'm not completely familair with the type testing lib. Does this implementation type check
foo: MessageWriter = container.resolve(MessageWriter)
If so, I'm impressed this was so straightforward!
There was a problem hiding this comment.
Added several examples 👍
| version = "0.7.1" | ||
| description = "An IOC Container for Python 3.8+" | ||
| description = "An IOC Container for Python 3.10+" | ||
| authors = [{ name = "Bob Gregory", email = "bob@codefiend.co.uk" }] |
|
I am going to merge this in a couple of days, if everything is good :) |
No description provided.