diff options
author | Gina Häußge <gina@octoprint.org> | 2022-02-01 14:57:01 +0300 |
---|---|---|
committer | Gina Häußge <gina@octoprint.org> | 2022-02-01 14:57:01 +0300 |
commit | 7fb9df99406957a85c623e14881d69d4a921518d (patch) | |
tree | 1a7a4f79f1bc1eb9b2a3a2abd9b414e59651b9d5 /docs | |
parent | 853e7f0765315accaa51374a45d25c205b531994 (diff) |
♻️ Migrate code base to Python 3 only
* pyupgrade
* various new codemods
* manual removal of Py2/3 compat imports
* manual adjustment of docs, examples, tests
* to_str is now the new to_unicode, deprecated
redirection to to_bytes has been removed
* to_native_str has been redirected to point to
to_str
* to_unicode has been redirected to point to
to_str
* atomic_write refactored to use
NamedTemporaryDirectory
* various other fixes/refactorings all over the
place
Diffstat (limited to 'docs')
-rw-r--r-- | docs/bundledplugins/backup.rst | 6 | ||||
-rw-r--r-- | docs/bundledplugins/softwareupdate.rst | 3 | ||||
-rw-r--r-- | docs/development/environment.rst | 121 | ||||
-rw-r--r-- | docs/plugins/controlproperties.rst | 9 | ||||
-rw-r--r-- | docs/plugins/gettingstarted.rst | 76 | ||||
-rw-r--r-- | docs/plugins/hooks.rst | 3 | ||||
-rw-r--r-- | docs/plugins/python3_migration.rst | 2 |
7 files changed, 51 insertions, 169 deletions
diff --git a/docs/bundledplugins/backup.rst b/docs/bundledplugins/backup.rst index 24be587e1..6dd70358c 100644 --- a/docs/bundledplugins/backup.rst +++ b/docs/bundledplugins/backup.rst @@ -120,9 +120,6 @@ octoprint.plugin.backup.additional_excludes .. code-block:: python - # -*- coding: utf-8 -*- - from __future__ import absolute_import, division, print_function, unicode_literals - import octoprint.plugin import os @@ -150,9 +147,6 @@ octoprint.plugin.backup.additional_excludes .. code-block:: python - # -*- coding: utf-8 -*- - from __future__ import absolute_import, division, print_function, unicode_literals - import octoprint.plugin import os diff --git a/docs/bundledplugins/softwareupdate.rst b/docs/bundledplugins/softwareupdate.rst index bb675ff86..78cf9de0c 100644 --- a/docs/bundledplugins/softwareupdate.rst +++ b/docs/bundledplugins/softwareupdate.rst @@ -635,9 +635,6 @@ octoprint.plugin.softwareupdate.check_config .. code-block:: python - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - def get_update_information(*args, **kwargs): return dict( updateplugindemo=dict( diff --git a/docs/development/environment.rst b/docs/development/environment.rst index b8d989ae3..1176f4df3 100644 --- a/docs/development/environment.rst +++ b/docs/development/environment.rst @@ -14,7 +14,7 @@ below. * Prerequisites: - * `Python 3.7 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv`` + * `Latest stable Python 3 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv`` * `Git <https://git-scm.com>`_ * Checkout the OctoPrint sources from their Git repository: @@ -24,15 +24,15 @@ below. * Enter the checked out source folder: ``cd OctoPrint`` * Create a virtual environment in the checked out source folder to use for installing and running OctoPrint and its dependencies. Creating virtual environments avoids potential versioning - issues for the dependencies with system wide installed instances: ``virtualenv --python=python3 venv3`` + issues for the dependencies with system wide installed instances: ``virtualenv --python=python3 venv`` .. note:: This assumes that the ``python3`` binary is available directly on your ``PATH``. If it cannot be found on your ``PATH`` like this you'll need to specify the full path here, - e.g. ``virtualenv --python=/path/to/python3/bin/python venv3`` + e.g. ``virtualenv --python=/path/to/python3/bin/python venv`` - * Activate the virtual environment: ``source venv3/bin/activate`` (Linux, macOS) or ``source venv3/Scripts/activate`` (Git Bash under Windows, see below) + * Activate the virtual environment: ``source venv/bin/activate`` (Linux, macOS) or ``source venv/Scripts/activate`` (Git Bash under Windows, see below) * Update ``pip`` in the virtual environment: @@ -61,31 +61,6 @@ When the virtual environment is activated you can then: folder -- the documentation will be available in the newly created ``_build`` directory. You can simply browse it locally by opening ``index.html`` -If a Python 2 environment is also desired (e.g. for maintenance reasons), also do the following extra steps: - - * Prerequisites: - - * `Python 2.7 <https://python.org>`_ including ``pip``, ``setuptools`` and ``virtualenv`` - - * Create a virtual environment in the checked out source folder for Python 2: ``virtualenv --python=python2 venv2`` - - .. note:: - - This assumes that the ``python2`` binary is available directly on your ``PATH``. If - it cannot be found on your ``PATH`` like this you'll need to specify the full path here, - e.g. ``virtualenv --python=/path/to/python2/bin/python venv2`` - - * Activate the virtual environment: ``source venv2/bin/activate`` (Linux, macOS) or ``source venv2/Scripts/activate`` (Git Bash under Windows, see below) - - * Update ``pip`` in the virtual environment: - - * ``pip install --upgrade pip`` - - * Install OctoPrint in `"editable" mode <https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs>`_, - including its regular *and* development and plugin development dependencies: - - * ``pip install -e '.[develop,plugins]'`` - .. _sec-development-environment-source-linux: Linux @@ -94,14 +69,14 @@ Linux This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different location, please substitute accordingly. -First make sure you have python 2 and 3 including their header files, pip, setuptools, virtualenv, git and some build requirements +First make sure you have python 3 including its header files, pip, setuptools, virtualenv, git and some build requirements installed: * On apt based distributions (e.g. Debian, Ubuntu, ...): .. code-block:: none - sudo apt-get install python python-pip python-dev python-setuptools python-virtualenv python3 python3-virtualenv python3-dev git libyaml-dev build-essential + sudo apt-get install python3 python3-pip python3-dev python3-setuptools python3-virtualenv git libyaml-dev build-essential Then: @@ -110,36 +85,13 @@ Then: cd ~/devel git clone https://github.com/OctoPrint/OctoPrint.git cd OctoPrint - virtualenv --python=python3 venv3 - source ./venv3/bin/activate + virtualenv --python=python3 venv + source ./venv/bin/activate pip install --upgrade pip pip install -e '.[develop,plugins,docs]' pre-commit install git config blame.ignoreRevsFile .git-blame-ignore-revs -.. _sec-development-environment-linux-python2: - -Optional Python 2 environment -............................. - -If a Python 2 environment is also desired: - - * On apt based distributions (e.g. Debian, Ubuntu, ...): - - .. code-block:: none - - sudo apt-get install python2 python2-dev python-pip python-setuptools python-virtualenv - -Then: - -.. code-block:: none - - virtualenv --python=python2 venv2 - source ./venv2/bin/activate - pip install --upgrade pip - pip install -e '.[develop,plugins]' - -You can then start OctoPrint via ``octoprint`` after activating one of the two virtual environments. .. todo:: @@ -180,38 +132,13 @@ Open the Git Bash you just installed and in that: cd /c/Devel git clone https://github.com/OctoPrint/OctoPrint.git cd OctoPrint - virtualenv --python=C:/Python3/python.exe venv3 - source ./venv3/Scripts/activate + virtualenv --python=C:/Python3/python.exe venv + source ./venv/Scripts/activate pip install --upgrade pip python -m pip install -e '.[develop,plugins,docs]' pre-commit install git config blame.ignoreRevsFile .git-blame-ignore-revs -.. _sec-development-environment-windows-python2: - -Optional Python 2 environment -............................. - -If a Python 2 environment is also desired, then also download and install - - * `Python 2.7.18 MSI installer <https://octoprint.org/files/python-2.7.18.msi>`_ (mirrored on octoprint.org) - - * it's recommended to install Python 2.7 into ``C:\Python27`` - if you select - different install locations please substitute accordingly - * it's also recommended to install for all users - - * `Microsoft Visual C++ Compiler for Python 2.7 <https://octoprint.org/files/VCForPython27.msi>`_ (mirrored on octoprint.org) - -Then: - -.. code-block:: none - - cd /c/Devel/OctoPrint - virtualenv --python=C:/Python27/python.exe venv2 - source ./venv2/Scripts/activate - python -m pip install --upgrade pip - pip install -e '.[develop,plugins]' - .. _sec-development-environment-windows-optional: Optional but recommended tools @@ -248,12 +175,6 @@ Mac OS X This guide is based on the `Setup Guide for Mac OS X on OctoPrint's Community Forum <https://community.octoprint.org/t/setting-up-octoprint-on-macos/13425>`_. Please report back if it works for you, due to lack of access to a Mac I cannot test it myself. Thanks. -.. todo:: - - This guide is not yet adapted to the concurrent use of Python 2 and 3 environments during development. Please send a - `Pull Request <https://github.com/OctoPrint/OctoPrint/blob/master/CONTRIBUTING.md#pull-requests>`_ to get the necessary - steps into this guide! - This assumes you'll host your OctoPrint development checkout at ``~/devel/OctoPrint``. If you want to use a different location, please substitute accordingly. @@ -266,7 +187,7 @@ You'll need a user account with administrator privileges. * ``sudo xcodebuild`` (ensure the license was accepted) * If you have more than one Xcode installed: ``sudo xcode-select -s /Applications/Xcode.app/Contents/Developer`` - * Install Homebrew and use that to install Python: + * Install Homebrew and use that to install Python 3: * ``ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`` * ``brew install python`` @@ -313,11 +234,11 @@ PyCharm - Register virtual environments: - **(Linux, Windows)** "File" > "Settings ..." > "Project: OctoPrint" > "Project Interpreter" > "Add local ...", - select OctoPrint ``venv3`` folder (e.g. ``~/devel/OctoPrint/venv3`` or ``C:\Devel\OctoPrint\venv3``). + select OctoPrint ``venv`` folder (e.g. ``~/devel/OctoPrint/venv`` or ``C:\Devel\OctoPrint\venv``). - **(macOS)** "PyCharm" > "Preferences ..." > "Project: OctoPrint" > "Project Interpreter" > "Add ..." > - "Virtualenv Environment > "Existing Environment", select OctoPrint ``venv3`` folder (e.g. ``~/devel/OctoPrint/venv3``). + "Virtualenv Environment > "Existing Environment", select OctoPrint ``venv`` folder (e.g. ``~/devel/OctoPrint/venv``). - If desired, repeat for the ``venv2`` folder, or any other additional Python venvs. + If desired, repeat for any other additional Python venvs (e.g. for separate Python 3 versions). - Right click "src" in project tree, mark as source folder - Add Run/Debug Configuration, select "Python": @@ -362,7 +283,7 @@ PyCharm * Module name: ``sphinx.cmd.build`` * Parameters: ``-v -T -E ./docs ./docs/_build -b html`` * Project: ``OctoPrint`` - * Python interpreter: ``venv3`` environment (the docs build requires Python 3) + * Python interpreter: ``venv`` environment * Working directory: the OctoPrint checkout folder (e.g. ``~/devel/OctoPrint`` or ``C:\Devel\OctoPrint``) * Just like with the run configuration for the server you can also have the dependencies auto-update when building the documentation, see above on how to set this up. @@ -375,14 +296,14 @@ PyCharm * Name: pre-commit * File type: Python * Scope: Module 'OctoPrint' - * Program: ``<OctoPrint venv3 folder>/bin/pre-commit`` (Linux) or ``<OctoPrint venv3 folder>/Scripts/pre-commit`` (Windows) + * Program: ``<OctoPrint venv folder>/bin/pre-commit`` (Linux) or ``<OctoPrint venv folder>/Scripts/pre-commit`` (Windows) * Arguments: ``run --hook-stage manual --files $FilePath$`` * Output paths to refresh: ``$FilePath$`` * Working directory: ``$ProjectFileDir$`` * disable "Auto-save edited files to trigger the watched" * enable "Trigger the watched on external changes" -To switch between virtual environments (e.g. Python 3 and 2), all you need to do now is change the Project Default Interpreter and restart +To switch between virtual environments (e.g. Python 3.7 and 3.8), all you need to do now is change the Project Default Interpreter and restart OctoPrint. On current PyCharm versions you can do that right from a small selection field in the footer of the IDE. Otherwise go through Settings. @@ -406,7 +327,7 @@ Visual Studio Code (vscode) .. code-block:: json { - "python.defaultInterpreterPath": "venv3/bin/python", + "python.defaultInterpreterPath": "venv/bin/python", "python.formatting.provider": "black", "python.formatting.blackArgs": [ "--config", @@ -466,7 +387,7 @@ Visual Studio Code (vscode) } ] } - + In the terminal install the python extension by running this command: .. code-block:: bash @@ -486,7 +407,7 @@ Visual Studio Code (vscode) * Your terminal inside vscode uses the virtual python environment * Saving a file will run an auto formatter and import sort - + * ``Ctrl+Shift+B`` can be used to run the ``build docs`` task to rebuild the documentation - + diff --git a/docs/plugins/controlproperties.rst b/docs/plugins/controlproperties.rst index c8ac018a0..b5905fa07 100644 --- a/docs/plugins/controlproperties.rst +++ b/docs/plugins/controlproperties.rst @@ -57,10 +57,13 @@ The following properties are recognized: ``__plugin_pythoncompat__`` Python compatibility string of your plugin, optional, defaults to ``>=2.7,<3`` if not set and thus Python 2 but no - Python 3 compatibility. + Python 3 compatibility. This is used as a precaution against issues with some of the Python 2 only plugins + that are still out there, as OctoPrint will not even attempt to load plugins whose Python compatibility + information doesn't match its current environment. - If your plugin is compatible to Python 3, you should set this to ``>=2.7,<4``, otherwise your plugin will not load - on OctoPrint instances installed under Python 3. + If your plugin is compatible to Python 3 only, you should set this to ``>=3.7,<4``. + + If your plugin is compatible to Python 2 and Python 3, you should set this to ``>=2.7,<4``. .. code-block:: python diff --git a/docs/plugins/gettingstarted.rst b/docs/plugins/gettingstarted.rst index 3ac2939d5..41765ab83 100644 --- a/docs/plugins/gettingstarted.rst +++ b/docs/plugins/gettingstarted.rst @@ -57,13 +57,10 @@ We'll start at the most basic form a plugin can take - just a few simple lines o .. code-block:: python :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - __plugin_name__ = "Hello World" __plugin_version__ = "1.0.0" __plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" Saving this as ``helloworld.py`` in ``~/.octoprint/plugins`` yields you something resembling these log entries upon server startup:: @@ -81,8 +78,9 @@ OctoPrint found that plugin in the folder and took a look into it. The name and entry it got from the ``__plugin_name__`` and ``__plugin_version__`` lines. It also read the description from ``__plugin_description__`` and stored it in an internal data structure, but we'll just ignore this for now. Additionally there is ``__plugin_pythoncompat__`` which tells OctoPrint here that your plugin can be run under any Python versions -between 2.7 and 4. That is necessary so that your plugin will be loadable in OctoPrint instances running under either -Python 2 or Python 3, and compatibility to both should be your goal. +between 3.7 and 4. That is necessary so that your plugin will be loadable in OctoPrint instances running under Python 3 +but not Python 2 (so you can use modern language features), and going forward you really should no longer have to care about +the end-of-life Python 2. .. _sec-plugins-gettingstarted-sayinghello: @@ -96,9 +94,6 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t :emphasize-lines: 4-8,14 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin): @@ -108,7 +103,7 @@ Apart from being discovered by OctoPrint, our plugin does nothing yet. We want t __plugin_name__ = "Hello World" __plugin_version__ = "1.0.0" __plugin_description__ = "A quick \"Hello World\" example plugin for OctoPrint" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() and restart OctoPrint. You now get this output in the log:: @@ -297,16 +292,13 @@ and ``__plugin_description__`` from ``__init__.py``, but leave ``__plugin_implem .. code-block:: python :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin): def on_after_startup(self): self._logger.info("Hello World!") - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() and restart OctoPrint:: @@ -320,12 +312,9 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the "OctoPrint-HelloWorld". That's a bit redundant and squashed, so we'll override that bit via ``__plugin_name__`` again: .. code-block:: python - :emphasize-lines: 10 + :emphasize-lines: 7 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin): @@ -333,7 +322,7 @@ Our "Hello World" Plugin still gets detected fine, but it's now listed under the self._logger.info("Hello World!") __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() @@ -369,12 +358,9 @@ navigation bar right at the top that links to the Wikipedia node about "Hello Wo add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class: .. code-block:: python - :emphasize-lines: 7 + :emphasize-lines: 4 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -383,7 +369,7 @@ add the :class:`TemplatePlugin` to our ``HelloWorldPlugin`` class: self._logger.info("Hello World!") __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Next, we'll create a sub folder ``templates`` underneath our ``octoprint_helloworld`` folder, and within that a file @@ -436,12 +422,9 @@ mixin. Let's take a look at how all that would look in our plugin's ``__init__.py``: .. code-block:: python - :emphasize-lines: 8, 10, 12-13 + :emphasize-lines: 5, 7, 9-10 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -454,7 +437,7 @@ Let's take a look at how all that would look in our plugin's ``__init__.py``: return dict(url="https://en.wikipedia.org/wiki/Hello_world") __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Restart OctoPrint. You should see something like this:: @@ -471,12 +454,9 @@ to add our URL as a template variable. Adjust your plugin's ``__init__.py`` like this: .. code-block:: python - :emphasize-lines: 15-16 + :emphasize-lines: 12-13 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -492,7 +472,7 @@ Adjust your plugin's ``__init__.py`` like this: return dict(url=self._settings.get(["url"])) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Also adjust your plugin's ``templates/helloworld_navbar.jinja2`` like this: @@ -579,12 +559,9 @@ for both our ``navbar`` and our ``settings`` plugin. We'll also remove the overr again since we don't use that anymore: .. code-block:: python - :emphasize-lines: 15-19 + :emphasize-lines: 12-16 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -603,7 +580,7 @@ again since we don't use that anymore: ] __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Restart OctoPrint and shift-reload your browser. Your link in the navigation bar should still point to the URL we @@ -677,12 +654,9 @@ just need to subclass :class:`~octoprint.plugin.AssetPlugin` and override its me like so: .. code-block:: python - :emphasize-lines: 9,22-25 + :emphasize-lines: 6,19-22 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -707,7 +681,7 @@ like so: ) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() Note how we did not add another entry to the return value of :func:`~octoprint.plugin.TemplatePlugin.get_template_configs`. @@ -858,12 +832,9 @@ Then adjust our plugin's ``__init__.py`` so that the :func:`~octoprint.plugin.As a reference to our CSS file: .. code-block:: python - :emphasize-lines: 26 + :emphasize-lines: 23 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -890,7 +861,7 @@ a reference to our CSS file: ) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() OctoPrint by default bundles all CSS, JavaScript and LESS files to reduce the amount of requests necessary to fully @@ -944,12 +915,9 @@ in the process. The folder structure of our plugin should now look like this:: Then adjust our returned assets to include our LESS file as well: .. code-block:: python - :emphasize-lines: 27 + :emphasize-lines: 24 :linenos: - # -*- coding: utf-8 -*- - from __future__ import absolute_import, unicode_literals - import octoprint.plugin class HelloWorldPlugin(octoprint.plugin.StartupPlugin, @@ -977,7 +945,7 @@ Then adjust our returned assets to include our LESS file as well: ) __plugin_name__ = "Hello World" - __plugin_pythoncompat__ = ">=2.7,<4" + __plugin_pythoncompat__ = ">=3.7,<4" __plugin_implementation__ = HelloWorldPlugin() diff --git a/docs/plugins/hooks.rst b/docs/plugins/hooks.rst index 1f65e91af..8a78c7785 100644 --- a/docs/plugins/hooks.rst +++ b/docs/plugins/hooks.rst @@ -28,7 +28,6 @@ or as ``postfix`` (after the existing lines). .. code-block:: python :linenos: - from past import basestring self._gcode_hooks = self._pluginManager.get_hooks("octoprint.comm.protocol.scripts") # ... @@ -45,7 +44,7 @@ or as ``postfix`` (after the existing lines). continue def to_list(data): - if isinstance(data, basestring): + if isinstance(data, str): data = map(x.strip() for x in data.split("\n")) if isinstance(data, (list, tuple)): diff --git a/docs/plugins/python3_migration.rst b/docs/plugins/python3_migration.rst index 170e039e7..1a85d2dc0 100644 --- a/docs/plugins/python3_migration.rst +++ b/docs/plugins/python3_migration.rst @@ -211,7 +211,7 @@ NOT need to convert to bytes when implementing API endpoints that return JSON, a anyhow. OctoPrint includes two utility methods you should use to ensure your strings enter/exit your code in the right format, -under both Python versions: :py:func:`octoprint.util.to_bytes` and :py:func:`octoprint.util.to_unicode`. Use them to ensure the correct data +under both Python versions: :py:func:`octoprint.util.to_bytes` and :py:func:`octoprint.util.to_str`. Use them to ensure the correct data types and to avoid weird conversion and encoding issues during runtime. You can read more about this specific issue in the corresponding section of the |