diff --git a/docs/sphinxext/codeblockext.py b/docs/sphinxext/codeblockext.py index cfbbadbb0..d21600121 100644 --- a/docs/sphinxext/codeblockext.py +++ b/docs/sphinxext/codeblockext.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +from __future__ import annotations __author__ = "Gina Häußge " __license__ = "The MIT License " @@ -20,9 +19,7 @@ from pygments.filters import VisibleWhitespaceFilter, ErrorToken from pygments.lexers.python import PythonConsoleLexer from pygments.util import ClassNotFound -if False: - # For type annotation - from typing import Any, Dict, List, Tuple # NOQA +from typing import Any def _merge_dict(a, b): @@ -75,8 +72,7 @@ class CodeBlockExt(CodeBlock): option_spec = _merge_dict(CodeBlock.option_spec, {"whitespace": directives.flag}) - def run(self): - # type: () -> List[nodes.Node] + def run(self) -> list[nodes.Node]: # get result from parent implementation code_block = CodeBlock.run(self) diff --git a/docs/sphinxext/onlineinclude.py b/docs/sphinxext/onlineinclude.py index 5344e3473..1e9356aeb 100644 --- a/docs/sphinxext/onlineinclude.py +++ b/docs/sphinxext/onlineinclude.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -from __future__ import absolute_import, division, print_function, unicode_literals +from __future__ import annotations __author__ = "Gina Häußge " __license__ = "The MIT License " @@ -21,16 +20,13 @@ from sphinx.directives.code import ( ) from sphinx.util.nodes import set_source_info -if False: - # For type annotation - from typing import Any, List # NOQA +from typing import Any cache = {} class OnlineIncludeReader(LiteralIncludeReader): - def read_file(self, filename, location=None): - # type: (unicode, Any) -> List[unicode] + def read_file(self, filename: str, location: Any = None) -> list[str]: global cache try: @@ -56,8 +52,7 @@ class OnlineIncludeReader(LiteralIncludeReader): class OnlineIncludeDirective(LiteralInclude): - def run(self): - # type: () -> List[nodes.Node] + def run(self) -> list[nodes.Node]: document = self.state.document if not document.settings.file_insertion_enabled: return [ diff --git a/src/octoprint/filemanager/storage.py b/src/octoprint/filemanager/storage.py index 8cd24d38c..007685d93 100644 --- a/src/octoprint/filemanager/storage.py +++ b/src/octoprint/filemanager/storage.py @@ -164,7 +164,7 @@ class StorageInterface: :param string path: the path of the new folder :param bool ignore_existing: if set to True, no error will be raised if the folder to be added already exists - :param unicode display: display name of the folder + :param str display: display name of the folder :return: the sanitized name of the new folder to be used for future references to the folder """ raise NotImplementedError() @@ -220,7 +220,7 @@ class StorageInterface: :param list links: any links to add with the file :param bool allow_overwrite: if set to True no error will be raised if the file already exists and the existing file and its metadata will just be silently overwritten - :param unicode display: display name of the file + :param str display: display name of the file :return: the sanitized name of the file to be used for future references to it """ raise NotImplementedError() diff --git a/src/octoprint/util/__init__.py b/src/octoprint/util/__init__.py index b7f5cb79e..70f95865f 100644 --- a/src/octoprint/util/__init__.py +++ b/src/octoprint/util/__init__.py @@ -77,7 +77,7 @@ def to_unicode( s_or_u: Union[str, bytes], encoding: str = "utf-8", errors: str = "strict" ) -> str: """ - Make sure ``s_or_u`` is a unicode string (str). + Make sure ``s_or_u`` is a string (str). Arguments: s_or_u (str or bytes): The value to convert @@ -202,7 +202,6 @@ def warning_factory(warning_type): "__dict__", "__doc__", "__str__", - "__unicode__", "__repr__", "__getattribute__", "__setattr__", @@ -1611,7 +1610,7 @@ class CaseInsensitiveSet(Set): """ Basic case insensitive set - Any str or unicode values will be stored and compared in lower case. Other value types are left as-is. + Any str values will be stored and compared in lower case. Other value types are left as-is. """ def __init__(self, *args):