From 1f8bcaf33cd8bd2b4552243306fcb4f7187412f7 Mon Sep 17 00:00:00 2001 From: "Jason K. Moore" Date: Thu, 17 Oct 2024 07:57:26 +0200 Subject: [PATCH 1/2] Deal with loss of whitespace in Python 3.13. --- .github/workflows/tests.yml | 2 +- opty-dev-env.yml | 1 + opty/direct_collocation.py | 9 +++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9392bee..b2bc0bf 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,7 +16,7 @@ jobs: matrix: # macos-13 is the last intel based runner os: [ubuntu-latest, macos-13, macos-latest, windows-latest] - python-version: ['3.9', '3.10', '3.11', '3.12'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] defaults: run: shell: bash -el {0} diff --git a/opty-dev-env.yml b/opty-dev-env.yml index cfd6442..e2e073a 100644 --- a/opty-dev-env.yml +++ b/opty-dev-env.yml @@ -11,6 +11,7 @@ dependencies: - numpydoc - pytest - pytest-cov + - python - scipy >=1.5.0 - sphinx - sphinx-gallery diff --git a/opty/direct_collocation.py b/opty/direct_collocation.py index 90783a5..b552b8a 100644 --- a/opty/direct_collocation.py +++ b/opty/direct_collocation.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -# + +import sys from functools import wraps import logging @@ -77,7 +78,11 @@ def use_parent_doc(self, func, source): @staticmethod def _combine_docs(prob_doc, coll_doc): beg, end = prob_doc.split('bounds') - _, middle = coll_doc.split('Parameters\n ==========\n ') + if sys.version_info[2] >= 13: + sep = 'Parameters\n==========\n' + else: + sep = 'Parameters\n ==========\n ' + _, middle = coll_doc.split(sep) return beg + middle[:-9] + ' bounds' + end _doc_inherit = _DocInherit From da57ccdc30a9fb68b9f54c800c24f2960d595b84 Mon Sep 17 00:00:00 2001 From: "Jason K. Moore" Date: Thu, 17 Oct 2024 07:58:57 +0200 Subject: [PATCH 2/2] Correct version check. --- opty/direct_collocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opty/direct_collocation.py b/opty/direct_collocation.py index b552b8a..6717524 100644 --- a/opty/direct_collocation.py +++ b/opty/direct_collocation.py @@ -78,7 +78,7 @@ def use_parent_doc(self, func, source): @staticmethod def _combine_docs(prob_doc, coll_doc): beg, end = prob_doc.split('bounds') - if sys.version_info[2] >= 13: + if sys.version_info[1] >= 13: sep = 'Parameters\n==========\n' else: sep = 'Parameters\n ==========\n '