-
Notifications
You must be signed in to change notification settings - Fork 12
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
Python 3.9 incompatibility "class must be set to a class, not 'ClassReloadr' object" #13
Comments
Looks like Python 3.9 changes the way it handles classes internally. I can reproduce the issue using Python 3.9 on Linux using Docker image Traceback:
|
The issue comes from https://github.com/hoh/reloadr/blob/master/reloadr.py#L31 : in Python 3.9, Below is a temporary patch. The issue of decorators should be handled in a better way. - 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", "")
+ source = source.replace("@autoreload\n", "").replace("@reloadr\n", "") |
@hoh If a regex approach is OK to remove all the decorators that follow @reloadr, then I can take this on me. I'd try to find time this week to work on it. I'd be looking to add a test for |
Hi @P6rguVyrst , The regex approach looks fine. It would be wise to also include the following names as aliases of that decorator:
Testing using Pytest sounds wise. Regarding the matrix of Python versions, either Tox or GitHub Actions seem fine. I would prefer the change that fixes this issue and a simple test in one PR, and the addition of Tox, GitHub Actions, ... in another since that is not entirely related. |
Took me a while, but I think I see what you mean. Do you mean that the solution should not be limited to
Makes it a more interesting problem, but wouldn't mind giving a go extending my initial solution and try to come up with a more complete solution. Technically speaking something like |
Has any further bug-fix progress been made ? |
I run 01_manual_reload.py in the examples directory,error is as follows:
TypeError: class must be set to a class, not 'ClassReloadr' object
python-BaseException.
I am using python3.9 on the win10 platform,What is the cause of this error?
The text was updated successfully, but these errors were encountered: