mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 01:47:36 +03:00 
			
		
		
		
	Refactor implementation
This commit is contained in:
		
							parent
							
								
									57366a1f7b
								
							
						
					
					
						commit
						316799ae6d
					
				
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
"""Containers module."""
 | 
					"""Containers module."""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import contextlib
 | 
					import contextlib
 | 
				
			||||||
import json
 | 
					import json
 | 
				
			||||||
import sys
 | 
					import sys
 | 
				
			||||||
| 
						 | 
					@ -258,8 +259,8 @@ class DynamicContainer(Container):
 | 
				
			||||||
        modules = [*modules] if modules else []
 | 
					        modules = [*modules] if modules else []
 | 
				
			||||||
        packages = [*packages] if packages else []
 | 
					        packages = [*packages] if packages else []
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if from_package is None and \
 | 
					        if _any_relative_string_imports_in(modules) or _any_relative_string_imports_in(packages):
 | 
				
			||||||
                (_has_any_relative_string_imports(modules) or _has_any_relative_string_imports(packages)):
 | 
					            if from_package is None:
 | 
				
			||||||
                with contextlib.suppress(Exception):
 | 
					                with contextlib.suppress(Exception):
 | 
				
			||||||
                    from_package = _resolve_calling_package_name()
 | 
					                    from_package = _resolve_calling_package_name()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -803,7 +804,7 @@ cpdef object _check_provider_type(object container, object provider):
 | 
				
			||||||
                           'instances'.format(container, container.provider_type))
 | 
					                           'instances'.format(container, container.provider_type))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cpdef bint _has_any_relative_string_imports(object modules):
 | 
					cpdef bint _any_relative_string_imports_in(object modules):
 | 
				
			||||||
    for module in modules:
 | 
					    for module in modules:
 | 
				
			||||||
        if not isinstance(module, str):
 | 
					        if not isinstance(module, str):
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -15,7 +15,6 @@ from typing import (
 | 
				
			||||||
    Callable,
 | 
					    Callable,
 | 
				
			||||||
    Any,
 | 
					    Any,
 | 
				
			||||||
    Tuple,
 | 
					    Tuple,
 | 
				
			||||||
    List,
 | 
					 | 
				
			||||||
    Dict,
 | 
					    Dict,
 | 
				
			||||||
    Generic,
 | 
					    Generic,
 | 
				
			||||||
    TypeVar,
 | 
					    TypeVar,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user