diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87ce973..e44f9e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,12 +22,9 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.4 hooks: - - id: flake8 - - - repo: https://github.com/psf/black - rev: 22.8.0 - hooks: - - id: black + - id: ruff + args: ["--fix", "--show-fixes"] + - id: ruff-format diff --git a/sphinx_exercise/__init__.py b/sphinx_exercise/__init__.py index 076f980..d729f72 100644 --- a/sphinx_exercise/__init__.py +++ b/sphinx_exercise/__init__.py @@ -144,7 +144,6 @@ def doctree_read(app: Sphinx, document: Node) -> None: def setup(app: Sphinx) -> Dict[str, Any]: - app.add_config_value("hide_solutions", False, "env") app.connect("config-inited", init_numfig) # event order - 1 diff --git a/sphinx_exercise/directive.py b/sphinx_exercise/directive.py index 5bf2027..1a1f21d 100644 --- a/sphinx_exercise/directive.py +++ b/sphinx_exercise/directive.py @@ -88,7 +88,6 @@ class : str, } def run(self) -> List[Node]: - self.defaults = {"title_text": "Exercise"} self.serial_number = self.env.new_serialno() @@ -163,7 +162,7 @@ def run(self) -> List[Node]: # Copy the node so that the post transforms do not modify this original state # Prior to Sphinx 6.1.0, the doctree was not cached, and Sphinx loaded a new copy # c.f. https://github.com/sphinx-doc/sphinx/commit/463a69664c2b7f51562eb9d15597987e6e6784cd - "node": node.deepcopy(), + "node": node.deepcopy(), } # TODO: Could tag this as Hidden to prevent the cell showing @@ -217,7 +216,6 @@ class : str, solution_node = solution_node def run(self) -> List[Node]: - self.defaults = {"title_text": "Solution to"} target_label = self.arguments[0] self.serial_number = self.env.new_serialno() diff --git a/sphinx_exercise/latex.py b/sphinx_exercise/latex.py index dd24ee1..6eb04fd 100644 --- a/sphinx_exercise/latex.py +++ b/sphinx_exercise/latex.py @@ -2,7 +2,6 @@ class LaTeXMarkup(object): - CR = "\n" def visit_admonition(self): diff --git a/sphinx_exercise/post_transforms.py b/sphinx_exercise/post_transforms.py index 6cd4ddc..32d49d2 100644 --- a/sphinx_exercise/post_transforms.py +++ b/sphinx_exercise/post_transforms.py @@ -47,7 +47,6 @@ class UpdateReferencesToEnumerated(SphinxPostTransform): default_priority = 5 def run(self): - if not hasattr(self.env, "sphinx_exercise_registry"): return @@ -113,7 +112,6 @@ def resolve_title(self, node): return node def run(self): - if not hasattr(self.env, "sphinx_exercise_registry"): return @@ -172,11 +170,9 @@ def resolve_solution_title(app, node, exercise_node): class ResolveTitlesInSolutions(SphinxPostTransform): - default_priority = 21 def run(self): - if not hasattr(self.env, "sphinx_exercise_registry"): return @@ -211,7 +207,6 @@ class ResolveLinkTextToSolutions(SphinxPostTransform): default_priority = 22 def run(self): - if not hasattr(self.env, "sphinx_exercise_registry"): return diff --git a/tests/conftest.py b/tests/conftest.py index b0a68ba..df54536 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -86,14 +86,14 @@ def file_regression(file_regression): class FileRegression: - ignores = ( ) + ignores = () changes = ( # TODO: Remove when support for Sphinx<=6 is dropped, (re.escape(" translation_progress=\"{'total': 0, 'translated': 0}\""), ""), # TODO: Remove when support for Sphinx<7.2 is dropped, (r"original_uri=\"[^\"]*\"\s", ""), # TODO: Remove when support for Sphinx<7.2 is dropped - ("Link to", "Permalink to") + ("Link to", "Permalink to"), ) def __init__(self, file_regression):