Просмотр исходного кода

Modernize RTD config, docs deps, tox env, and stdlib usage

.readthedocs.yaml: add the now-required build.os, build.tools.python,
and sphinx.configuration blocks — RTD retired the implicit-defaults
build platform in late 2024.

docs/conf.py: drop vestigial `import sphinx_rtd_theme` and the
html_theme_path call (sphinx_rtd_theme >= 1.0 auto-discovers via
entry points); bump copyright through 2026.

docs/requirements.txt: raise floors to sphinx>=8 / sphinx_rtd_theme>=3
and drop the comment about a long-resolved sphinx bug.

tox.ini: remove the pypy environment from envlist — CI never ran it,
and pypy can't realistically build the Azure SDK's C extensions.

requirements.txt: drop sshpubkeys (was a moto 1.0.0 workaround; we run
moto 5.x now).

cloudbridge/__init__.py: replace the custom NullHandler subclass with
logging.NullHandler (in stdlib since Py3.1).

Add TODO.rst capturing the deferred mechanical sweeps (object base
class, super(), f-strings, typing builtins, ruff/mypy, pre-existing
flake8 import-order errors, untracked dev artifacts).
Nuwan Goonasekera 6 часов назад
Родитель
Сommit
a8a2f4551e
7 измененных файлов с 60 добавлено и 22 удалено
  1. 10 2
      .readthedocs.yaml
  2. 45 0
      TODO.rst
  3. 1 9
      cloudbridge/__init__.py
  4. 1 5
      docs/conf.py
  5. 2 3
      docs/requirements.txt
  6. 0 2
      requirements.txt
  7. 1 1
      tox.ini

+ 10 - 2
.readthedocs.yaml

@@ -1,5 +1,13 @@
 version: 2
 
+build:
+  os: ubuntu-24.04
+  tools:
+    python: "3.13"
+
+sphinx:
+  configuration: docs/conf.py
+
 python:
-   install:
-   - requirements: docs/requirements.txt
+  install:
+  - requirements: docs/requirements.txt

+ 45 - 0
TODO.rst

@@ -0,0 +1,45 @@
+Deferred Modernization Work
+===========================
+
+The packaging migration (setup.py → pyproject.toml, drop six, refresh docs)
+landed in commits ``7df4a94``..``HEAD``. The items below were identified
+during that sweep but deliberately left out because each is large enough
+to warrant its own focused PR.
+
+Mechanical Python idiom updates
+-------------------------------
+
+Each of these is a near-mechanical refactor with a wide diff. Best done
+one-at-a-time so reviewers can read each change as a single transformation.
+
+* **Drop explicit ``object`` base class.** ``class Foo(object):`` →
+  ``class Foo:``. No behavior change in Py3.
+* **Modernize ``super()`` calls.** ``super(ClassName, self).method(...)`` →
+  ``super().method(...)``. The arguments are required only in Py2.
+* **Adopt f-strings.** ``"x={0}".format(x)`` and ``"x=%s" % x`` →
+  ``f"x={x}"``. Skip for logging calls — those should keep ``%s``
+  formatting so the logger can short-circuit when the level is disabled.
+* **Switch typing imports to builtins.** ``List[X]`` / ``Dict[K, V]`` /
+  ``Optional[X]`` → ``list[X]`` / ``dict[K, V]`` / ``X | None`` once a
+  Python 3.10+ floor is acceptable (we already require 3.13, so this is
+  safe today).
+
+Lint and tooling
+----------------
+
+* **Fix the ~23 pre-existing flake8 import-order errors.** Run
+  ``tox -e lint`` to see the list. Mostly ``I100``/``I201``/``I202``
+  under ``cloudbridge/providers/azure``, ``gcp``, and ``openstack``.
+* **Consider replacing flake8 + flake8-import-order with ruff.** Ruff
+  reads ``pyproject.toml``, runs ~100× faster, and covers import
+  ordering (``I``) plus most flake8 plugins out of the box.
+* **Consider adding mypy / pyright in CI.** The codebase has no type
+  hints today; this would be a meaningful uplift, not a one-PR task.
+
+Repository hygiene
+------------------
+
+* **Untracked local-dev artifacts at the repo root** — ``azure.txt``,
+  ``openstack.txt``, ``docs2/``, ``script_test.py``, ``openstack.log``.
+  Each likely belongs in ``.gitignore`` or in a developer's untracked
+  workspace; investigate before either committing or deleting.

+ 1 - 9
cloudbridge/__init__.py

@@ -25,14 +25,6 @@ def init_logging():
     set_stream_logger(__name__, level=logging.DEBUG)
 
 
-class NullHandler(logging.Handler):
-    """A null handler for the logger."""
-
-    def emit(self, record):
-        """Don't emit a log."""
-        pass
-
-
 TRACE = 5  # Lower than debug which is 10
 
 
@@ -58,7 +50,7 @@ default_format_string = "%(asctime)s [%(levelname)s] %(name)s: %(message)s"
 logging.setLoggerClass(CBLogger)
 logging.addLevelName(TRACE, "TRACE")
 log = logging.getLogger('cloudbridge')
-log.addHandler(NullHandler())
+log.addHandler(logging.NullHandler())
 
 # Convenience functions to set logging to a particular file or stream
 # To enable either of these by default within CloudBridge, add the following

+ 1 - 5
docs/conf.py

@@ -15,13 +15,12 @@ import sys
 
 sys.path.insert(0, os.path.abspath('../'))
 
-import sphinx_rtd_theme
 import cloudbridge
 
 # -- Project information -----------------------------------------------------
 
 project = 'cloudbridge'
-copyright = '2021, GVL and Galaxy Projects'
+copyright = '2015-2026, GVL and Galaxy Projects'
 author = 'GVL and Galaxy Projects'
 
 # The full version, including alpha/beta/rc tags
@@ -57,9 +56,6 @@ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
 #
 html_theme = 'sphinx_rtd_theme'
 
-# Add any paths that contain custom themes here, relative to this directory.
-html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
-
 # Add any paths that contain custom static files (such as style sheets) here,
 # relative to this directory. They are copied after the builtin static files,
 # so a file named "default.css" will overwrite the builtin "default.css".

+ 2 - 3
docs/requirements.txt

@@ -1,3 +1,2 @@
-# https://github.yuuza.net/sphinx-doc/sphinx/issues/9727
-sphinx>=4.2.0
-sphinx_rtd_theme>=1.0.0
+sphinx>=8.0
+sphinx_rtd_theme>=3.0

+ 0 - 2
requirements.txt

@@ -1,3 +1 @@
-# needed by moto
-sshpubkeys
 -e ".[dev]"

+ 1 - 1
tox.ini

@@ -6,7 +6,7 @@
 # running the tests.
 
 [tox]
-envlist = {py3.13,pypy}-{aws,azure,gcp,openstack,mock},lint
+envlist = py3.13-{aws,azure,gcp,openstack,mock},lint
 
 [testenv]
 commands = # see pyproject.toml for coverage options; setup.cfg for flake8