mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 01:47:36 +03:00 
			
		
		
		
	Add support of positional context argument injections
This commit is contained in:
		
							parent
							
								
									f1cc113e33
								
							
						
					
					
						commit
						671bb42bbb
					
				| 
						 | 
				
			
			@ -18,6 +18,7 @@ positional argument injections the same way as :py:class:`Factory` provider:
 | 
			
		|||
+ Providers could be injected "as is" (delegated), if it is defined explicitly. Check out
 | 
			
		||||
  :ref:`factory_providers_delegation`.
 | 
			
		||||
+ All other values are injected *"as is"*.
 | 
			
		||||
+ Positional context arguments will be appended after :py:class:`List` positional injections.
 | 
			
		||||
 | 
			
		||||
Full example:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +29,6 @@ Full example:
 | 
			
		|||
 | 
			
		||||
.. note::
 | 
			
		||||
 | 
			
		||||
    Positional context argument injections and keyword argument injections are not
 | 
			
		||||
    supported.
 | 
			
		||||
    Keyword argument injections are not supported.
 | 
			
		||||
 | 
			
		||||
.. disqus::
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -1972,8 +1972,7 @@ cdef class List(Provider):
 | 
			
		|||
    :py:class:`List` provider is needed for injecting a list of dependencies. It handles
 | 
			
		||||
    positional argument injections the same way as :py:class:`Factory` provider.
 | 
			
		||||
 | 
			
		||||
    Positional context argument injections and keyword argument injections are not
 | 
			
		||||
    supported.
 | 
			
		||||
    Keyword argument injections are not supported.
 | 
			
		||||
 | 
			
		||||
    .. code-block:: python
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,6 +23,11 @@ class ListTests(unittest.TestCase):
 | 
			
		|||
 | 
			
		||||
        self.assertIsNot(list1, list2)
 | 
			
		||||
 | 
			
		||||
    def test_call_with_context_args(self):
 | 
			
		||||
        provider = providers.List('i1', 'i2')
 | 
			
		||||
 | 
			
		||||
        self.assertEqual(provider('i3', 'i4'), ['i1', 'i2', 'i3', 'i4'])
 | 
			
		||||
 | 
			
		||||
    def test_fluent_interface(self):
 | 
			
		||||
        provider = providers.List() \
 | 
			
		||||
            .add_args(1, 2)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user