|
85 | 85 | from itertools import chain |
86 | 86 | from operator import attrgetter |
87 | 87 | from tempfile import NamedTemporaryFile |
88 | | -from types import FunctionType, ModuleType, SimpleNamespace |
| 88 | +from types import FunctionType, SimpleNamespace |
89 | 89 |
|
90 | 90 | __version__ = "0.9.0" |
91 | 91 |
|
@@ -905,37 +905,6 @@ def process_list_cmd(self, arg): |
905 | 905 | for line_no, line in enumerate(src_lines, offset + 1): |
906 | 906 | self.write(cyan(f"{line_no:03d}: {line}")) |
907 | 907 |
|
908 | | - @_doc_to_usage |
909 | | - def process_reload_cmd(self, arg): |
910 | | - """{config.RELOAD_CMD} <object> - Reload object, if possible. |
911 | | -
|
912 | | - - if argument is a module, simply call importlib.reload() for it. |
913 | | -
|
914 | | - - if argument is not a module, try hard to re-execute the |
915 | | - (presumably updated) source code in the namespace of the object, |
916 | | - in effect reloading it. |
917 | | -
|
918 | | - credit: inspired by the description at https://github.com/hoh/reloadr |
919 | | - """ |
920 | | - if not arg: |
921 | | - return self.writeline( |
922 | | - "reload command requires an " f"argument (eg: {config.RELOAD_CMD} foo)" |
923 | | - ) |
924 | | - |
925 | | - try: |
926 | | - obj = self.lookup(arg) |
927 | | - if isinstance(obj, ModuleType): |
928 | | - self.locals[arg] = importlib.reload(obj) |
929 | | - else: |
930 | | - namespace = inspect.getmodule(obj) |
931 | | - exec( |
932 | | - compile(inspect.getsource(obj), namespace.__file__, "exec"), |
933 | | - namespace.__dict__, |
934 | | - self.locals, |
935 | | - ) |
936 | | - except OSError as e: |
937 | | - self.writeline(e) |
938 | | - |
939 | 908 | def process_help_cmd(self, arg): |
940 | 909 | if arg: |
941 | 910 | if keyword.iskeyword(arg): |
|
0 commit comments