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
Import ABC from collections.abc for Python 3.10 compatibility. #4043
Conversation
Would it be possible for these to be behind error handled blocks and against the maintenance branch, so it can go out before the 2.0.0 release dropping Python 2? That would be the ideal here, using some error handling to make it work on Python 2.7 as well. Also, as a side note - these were finally removed in Py 3.10? It's been warning about it being removed for Py3.8, then 3.9, then 3.10.... |
I tried to give this a test, while it probably works on Python 3.10 there's a slightly larger issue with frozendict: Traceback (most recent call last):
File "C:\Users\charl.TERRANCE\Development\venv310\Scripts\octoprint-script.py", line 33, in <module>
sys.exit(load_entry_point('OctoPrint', 'console_scripts', 'octoprint')())
File "c:\users\charl.terrance\development\octoprint core\octoprint\src\octoprint\__init__.py", line 913, in main
from octoprint.cli import octo
File "c:\users\charl.terrance\development\octoprint core\octoprint\src\octoprint\cli\__init__.py", line 282, in <module>
from .dev import dev_commands # noqa: E402
File "c:\users\charl.terrance\development\octoprint core\octoprint\src\octoprint\cli\dev.py", line 259, in <module>
def dev():
File "c:\users\charl.terrance\development\venv310\lib\site-packages\click\core.py", line 1377, in decorator
cmd = group(*args, **kwargs)(f)
File "c:\users\charl.terrance\development\venv310\lib\site-packages\click\decorators.py", line 130, in decorator
cmd = _make_command(f, name, attrs, cls)
File "c:\users\charl.terrance\development\venv310\lib\site-packages\click\decorators.py", line 98, in _make_command
return cls(
File "c:\users\charl.terrance\development\octoprint core\octoprint\src\octoprint\cli\dev.py", line 26, in __init__
from octoprint.util.commandline import CommandlineCaller
File "c:\users\charl.terrance\development\octoprint core\octoprint\src\octoprint\util\__init__.py", line 27, in <module>
import frozendict
File "c:\users\charl.terrance\development\venv310\lib\site-packages\frozendict\__init__.py", line 16, in <module>
class frozendict(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping' It does not appear to be maintained any longer, though there are alternatives around and people trying to claim the frozen dict project to bring it up to speed. |
f9c145a
to
aa395c9
Compare
Thanks added try/except and rebased. This was delayed couple of times and removed in python/cpython#23754 for Python 3.10 |
That looks good to me - obviously the problem of frozendict dependency will have to be solved as well (and maybe something else) but this is at least part of it. 3.10 is still in alpha, so we have 6 months or so to come up with a solution 🙂. I did poke about and saw there was a request for the frozendict package to be adopted on PyPi that was approved, the original maintainer is OK for it to be transferred. So once they get through the backlog it may be simple enough to upgrade - though my bets are it won't support Python 2. Maybe by then we will be closer to a working 2.0 release 😉 |
Took the liberty to squash and change base to |
frozendict appears to be unmaintained and is incompatible to Python 3.10+ As discussed in #4043
Python 3.10 introduces a backwards incompatible change around collections and collections.abcs, which tornado was impacted by. According to Tornado's release notes https://www.tornadoweb.org/en/stable/releases/v6.0.0.html seem like there is not much else to worry about, and the devel branch has already upgraded it. Would be good to get this tested by someone else using Python 3.10 and some plugins, and also some Python 2 installs. See also OctoPrint#4043 for the other collections-related changes.
Python 3.10 introduces a backwards incompatible change around collections and collections.abcs, which tornado was impacted by. According to Tornado's release notes https://www.tornadoweb.org/en/stable/releases/v6.0.0.html seem like there is not much else to worry about, and the devel branch has already upgraded it. Would be good to get this tested by someone else using Python 3.10 and some plugins, and also some Python 2 installs. See also #4043 for the other collections-related changes.
to a large audience (ideally all users of OctoPrint)
made sure your changes don't interfere with current development by
talking it through with the maintainers, e.g. through a
Brainstorming ticket
new feature, or maintenance if it's a bug fix or improvement of
existing functionality for the current stable version (no PRs
against master or anything else please)
(no PRs from your version of master, maintenance or devel please),
e.g. dev/my_new_feature or fix/my_bugfix
no dead code, ideally only one commit - rebase and squash your PR
if necessary!
.less source files, not the .css files (those are generated with
lessc)
have added unit tests
nothing broke
What does this PR do and why is it necessary?
Importing ABC directly from collections has been deprecated and removed in Python 3.10 . This PR updates the relevant places
How was it tested? How can it be tested by the reviewer?
Any background context you want to provide?
What are the relevant tickets if any?
Similar to #3735
Screenshots (if appropriate)
Further notes