Skip to content

Commit

Permalink
0.14.2
Browse files Browse the repository at this point in the history
  • Loading branch information
EcmaXp committed Jun 1, 2024
1 parent cdbdd17 commit 0b996fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "reloader.py"
version = "0.14.1"
version = "0.14.2"
description = "A simple script reloader"
license = "MIT"
authors = ["EcmaXp <[email protected]>"]
Expand Down
15 changes: 8 additions & 7 deletions reloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from watchdog.utils.event_debouncer import EventDebouncer

__author__ = "EcmaXp"
__version__ = "0.14.1"
__version__ = "0.14.2"
__license__ = "MIT"
__url__ = "https://pypi.org/project/reloader.py/"
__all__ = [
Expand Down Expand Up @@ -275,7 +275,7 @@ def name(self):

@property
def file(self):
return self.module.__file__
return inspect.getfile(self.module)

@property
def path(self):
Expand Down Expand Up @@ -484,12 +484,13 @@ def get_code_module(self, module_name: str) -> CodeModule | ScriptModule | None:
@staticmethod
def _check_module(module: ModuleType):
try:
return module.__loader__.get_source(module.__name__) is not None # noqa
except (AttributeError, ImportError, TypeError):
inspect.getsource(module)
return True
except (OSError, TypeError):
return False

def watch_module(self, module: ModuleType) -> CodeModule:
code_module = self._code_modules.get(module.__file__)
code_module = self._code_modules.get(inspect.getfile(module))
if code_module is None:
code_module = CodeModule(module)
self.watch_code_module(code_module)
Expand All @@ -502,8 +503,8 @@ def watch_script(self, script_path: Path | PathLike) -> ScriptModule:
return script_module

def watch_code_module(self, code_module: CodeModule) -> None:
self._code_modules[code_module.module.__file__] = code_module
self._watchdog_handler.schedule(code_module.module.__file__)
self._code_modules[code_module.file] = code_module
self._watchdog_handler.schedule(code_module.file)

def watch_resource(self, path: Path | PathLike | str) -> None:
path = Path(path).resolve()
Expand Down

0 comments on commit 0b996fb

Please sign in to comment.