From 534a45c6da2acd762a7047c1432a3000c15e4e35 Mon Sep 17 00:00:00 2001 From: Alex Sichkar Date: Sat, 18 Apr 2020 20:57:36 +0300 Subject: [PATCH] Fix #172 (#174) --- split_settings/tools.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/split_settings/tools.py b/split_settings/tools.py index e184d1e..307d347 100644 --- a/split_settings/tools.py +++ b/split_settings/tools.py @@ -11,7 +11,7 @@ import inspect import os import sys -import types +from importlib.util import module_from_spec, spec_from_file_location __all__ = ('optional', 'include') # noqa: WPS410 @@ -114,8 +114,10 @@ def include(*args: str, **kwargs) -> None: # noqa: WPS210, WPS231, C901 rel_path[:rel_path.rfind('.')].replace('/', '.'), ) - module = types.ModuleType(str(module_name)) - module.__file__ = included_file # noqa: WPS609 + spec = spec_from_file_location( + module_name, included_file, + ) + module = module_from_spec(spec) sys.modules[module_name] = module if saved_included_file: scope[_INCLUDED_FILE] = saved_included_file