-
Notifications
You must be signed in to change notification settings - Fork 94
fix: Multibind scopes #284
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #284 +/- ##
==========================================
+ Coverage 95.84% 95.98% +0.13%
==========================================
Files 1 1
Lines 602 623 +21
Branches 103 106 +3
==========================================
+ Hits 577 598 +21
Misses 19 19
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
_BindingBase = namedtuple('_BindingBase', 'interface provider scope') | ||
@dataclass | ||
class _BindingBase: | ||
interface: type | ||
provider: Provider | ||
scope: Type['Scope'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to get more type-checking confidence in my work, I converted this named tuple to a dataclass.
TYPE_CHECKING, | ||
Any, | ||
Callable, | ||
cast, | ||
Dict, | ||
Generator, | ||
Generic, | ||
get_args, | ||
Iterable, | ||
List, | ||
Optional, | ||
overload, | ||
Set, | ||
Tuple, | ||
Type, | ||
TypeVar, | ||
TYPE_CHECKING, | ||
Union, | ||
cast, | ||
get_args, | ||
overload, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imports got sorted when I ran black
def get(self, unused_key: Type[T], provider: Provider[T]) -> Provider[T]: | ||
def get(self, key: Type[T], provider: Provider[T]) -> Provider[T]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by: fix invalid override (keyword arguments must match that of the method being overridden).
AssistedBuilder, | ||
Binder, | ||
CallError, | ||
CircularDependency, | ||
ClassAssistedBuilder, | ||
ClassProvider, | ||
Error, | ||
Inject, | ||
Injector, | ||
InstanceProvider, | ||
InvalidInterface, | ||
Module, | ||
NoInject, | ||
ProviderOf, | ||
Scope, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran black on this file as well, which caused the imports to be sorted
What
Change how the
scope
argument of themultibind
method works, so that it applies to the target rather than the containing list or dictionary. Also, consider explicit class bindings when resolving multibindings, and honor the scope of the class binding when the multibinding has no scope.Why
So that it becomes possible to control the scope of individual multi-bindings. E.g.
Closes #283