From ea348fea641dd03bea518318873b320767409ef9 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Tue, 30 Jul 2024 02:42:32 +0200 Subject: [PATCH 1/3] Remove some old Python 2 code (#949) --- breathe/apidoc.py | 14 ++------------ breathe/parser/compound.py | 4 ++-- breathe/parser/compoundsuper.py | 4 ++-- breathe/parser/index.py | 2 +- breathe/parser/indexsuper.py | 2 +- tests/warnings/source/conf.py | 1 - 6 files changed, 8 insertions(+), 19 deletions(-) diff --git a/breathe/apidoc.py b/breathe/apidoc.py index e7ff33eb9..198966805 100644 --- a/breathe/apidoc.py +++ b/breathe/apidoc.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ breathe.apidoc ~~~~~~~~~~~~~~ @@ -14,7 +13,6 @@ :copyright: Originally by Sphinx Team, C++ modifications by Tatsuyuki Ishi :license: BSD, see LICENSE for details. """ -from __future__ import print_function import os import sys @@ -24,14 +22,6 @@ from breathe import __version__ -# Account for FileNotFoundError in Python 2 -# IOError is broader but will hopefully suffice -try: - FileNotFoundError -except NameError: - FileNotFoundError = IOError - - # Reference: Doxygen XSD schema file, CompoundKind only # Only what breathe supports are included # Translates identifier to English @@ -71,7 +61,7 @@ def write_file(name, text, args): if exc.errno != errno.EEXIST: raise try: - with open(fname, "r") as target: + with open(fname) as target: orig = target.read() if orig == text: print_info("File %s up to date, skipping." % fname, args) @@ -141,7 +131,7 @@ def recurse_tree(args): class TypeAction(argparse.Action): def __init__(self, option_strings, dest, **kwargs): - super(TypeAction, self).__init__(option_strings, dest, **kwargs) + super().__init__(option_strings, dest, **kwargs) self.default = TYPEDICT.keys() self.metavar = ",".join(TYPEDICT.keys()) diff --git a/breathe/parser/compound.py b/breathe/parser/compound.py index da6ee69bf..cf858d7da 100644 --- a/breathe/parser/compound.py +++ b/breathe/parser/compound.py @@ -927,7 +927,7 @@ def __init__(self, char=None, valueOf_=''): # end class docCharTypeSub -class verbatimTypeSub(object): +class verbatimTypeSub: """ New node type. Structure is largely pillaged from other nodes in order to match the set. @@ -1200,7 +1200,7 @@ def parse(inFilename): try: doc = minidom.parse(inFilename) - except IOError as e: + except OSError as e: raise FileIOError(e) except ExpatError as e: raise ParseError(e) diff --git a/breathe/parser/compoundsuper.py b/breathe/parser/compoundsuper.py index 79050eddb..3c01da9ca 100644 --- a/breathe/parser/compoundsuper.py +++ b/breathe/parser/compoundsuper.py @@ -134,7 +134,7 @@ def getName(self): return self.name -class _MemberSpec(object): +class _MemberSpec: def __init__(self, name='', data_type='', container=0): self.name = name self.data_type = data_type @@ -2632,7 +2632,7 @@ def buildChildren(self, child_, nodeName_): value_.append(text_.nodeValue) # We make this unicode so that our unicode renderer catch-all picks it up # otherwise it would go through as 'str' and we'd have to pick it up too - valuestr_ = u' ' + valuestr_ = ' ' obj_ = self.mixedclass_(MixedContainer.CategorySimple, MixedContainer.TypeString, 'sp', valuestr_) self.content_.append(obj_) diff --git a/breathe/parser/index.py b/breathe/parser/index.py index 3788991ee..d4f0634bf 100644 --- a/breathe/parser/index.py +++ b/breathe/parser/index.py @@ -49,7 +49,7 @@ class FileIOError(Exception): def parse(inFilename): try: doc = minidom.parse(inFilename) - except IOError as e: + except OSError as e: raise FileIOError(e) except ExpatError as e: raise ParseError(e) diff --git a/breathe/parser/indexsuper.py b/breathe/parser/indexsuper.py index 4c7126ceb..8f748455b 100644 --- a/breathe/parser/indexsuper.py +++ b/breathe/parser/indexsuper.py @@ -129,7 +129,7 @@ def getName(self): return self.name -class _MemberSpec(object): +class _MemberSpec: def __init__(self, name='', data_type='', container=0): self.name = name self.data_type = data_type diff --git a/tests/warnings/source/conf.py b/tests/warnings/source/conf.py index 3dfc126d1..3b63231ff 100644 --- a/tests/warnings/source/conf.py +++ b/tests/warnings/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # Test Breathe Warnings documentation build configuration file, created by # sphinx-quickstart on Thu Jun 5 18:57:21 2014. From 09c856bf72de41e82582f31855e916295ba6d382 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Tue, 30 Jul 2024 01:44:21 +0100 Subject: [PATCH 2/3] Update `test_renderer` so that tests pass with Sphinx 7.2 (#976) Sphinx was updated in July 2023 so that importing `sphinx.testing.path` no longer causes Sphinx application paths to belong to the class `sphinx.testing.path.path`, which has a `makedirs` method. Instead, Sphinx application paths are now ordinary `Path` objects which lack this method, so we use `os.makedirs` instead. This is backwards compatible as `sphinx.testing.path.path` objects are pathlike and so accepted by `os.makedirs`. --- tests/test_renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_renderer.py b/tests/test_renderer.py index a858c65d8..0fd044a5c 100644 --- a/tests/test_renderer.py +++ b/tests/test_renderer.py @@ -35,7 +35,7 @@ def app(test_params, app_params, make_app, shared_result): """ args, kwargs = app_params assert "srcdir" in kwargs - kwargs["srcdir"].makedirs(exist_ok=True) + os.makedirs(kwargs["srcdir"], exist_ok=True) (kwargs["srcdir"] / "conf.py").write_text("") app_ = make_app(*args, **kwargs) yield app_ From caa8dc45222b35d360c24bf36835a7d8e6d86df2 Mon Sep 17 00:00:00 2001 From: Scott Main Date: Mon, 29 Jul 2024 17:45:36 -0700 Subject: [PATCH 3/3] Fix PosixPath issue with Sphinx 7.2 (#964) --- breathe/project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breathe/project.py b/breathe/project.py index 865236e80..f5b780a4e 100644 --- a/breathe/project.py +++ b/breathe/project.py @@ -113,7 +113,7 @@ def __init__(self, app: Sphinx): # Assume general build directory is the doctree directory without the last component. # We strip off any trailing slashes so that dirname correctly drops the last part. # This can be overridden with the breathe_build_directory config variable - self._default_build_dir = os.path.dirname(app.doctreedir.rstrip(os.sep)) + self._default_build_dir = os.path.dirname(str(app.doctreedir).rstrip(os.sep)) self.project_count = 0 self.project_info_store: Dict[str, ProjectInfo] = {} self.project_info_for_auto_store: Dict[str, AutoProjectInfo] = {}