Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look into issue #13, and see if I can figure out how to fix it. #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
env/
venv/
*.egg-info/
12 changes: 7 additions & 5 deletions reloadr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any
from time import sleep

import re
import inspect
import threading
import types
Expand All @@ -14,7 +15,7 @@
from watchdog.observers import Observer

__author__ = "Hugo Herter"
__version__ = '0.4.1'
__version__ = '0.4.2'


def get_new_source(target, kind: str) -> str:
Expand All @@ -26,11 +27,12 @@ def get_new_source(target, kind: str) -> str:
"""
assert kind in ('class', 'def')
source = inspect.getsource(target)
match_decorators = re.compile(
r"@reloadr(.*)(?=class)",
re.DOTALL,
)
source = re.sub(match_decorators, '', source)

if kind == 'def':
# `inspect.getsource` will not return the decorators in the source of classes,
# but will return them in the source of functions.
source = source.replace("@autoreload\n", "")
return source


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
long_description = file.read()

setup(name='Reloadr',
version='0.4.1',
version='0.4.2',
description='Hot code reloading tool for Python',
long_description=long_description,
author='Hugo Herter',
Expand Down