diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a86bf05..41f915f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.11.2 hooks: - id: ruff name: ruff unused imports diff --git a/.ruff.toml b/.ruff.toml index 594c8d8..a22554f 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -34,8 +34,6 @@ ignore = [ "UP038", # Use X | Y in {} call instead of (X, Y) # https://docs.astral.sh/ruff/rules/#flake8-annotations-ann - "ANN101", # Missing type annotation for {name} in method - "ANN102", # Missing type annotation for {name} in classmethod "ANN401", # Dynamically typed expressions (typing.Any) are disallowed in {name} # https://docs.astral.sh/ruff/rules/#flake8-blind-except-ble diff --git a/readme.md b/readme.md index ba1a6ef..deda47e 100644 --- a/readme.md +++ b/readme.md @@ -36,6 +36,9 @@ This code will be executed ``` # Changelog +#### 0.16 (2025-04-01) +- Fixed an issue where the ``hide`` and ``hide_output`` options were not working correctly + #### 0.15 (2024-12-10) - Removed confusing log output diff --git a/src/sphinx_exec_code/__version__.py b/src/sphinx_exec_code/__version__.py index a3e6290..6c1078b 100644 --- a/src/sphinx_exec_code/__version__.py +++ b/src/sphinx_exec_code/__version__.py @@ -1 +1 @@ -__version__ = '0.15' +__version__ = '0.16' diff --git a/src/sphinx_exec_code/sphinx_spec.py b/src/sphinx_exec_code/sphinx_spec.py index 58a1d6e..d3e932e 100644 --- a/src/sphinx_exec_code/sphinx_spec.py +++ b/src/sphinx_exec_code/sphinx_spec.py @@ -24,7 +24,7 @@ def post_process_spec(spec: Dict[str, Any], options: Dict[str, Any]) -> None: raise NotImplementedError() def __init__(self, spec: Dict[str, Any]) -> None: - self.hide: Final = spec.pop('hide') + self.hide: Final = spec.pop('hide', '') is None self.language: Final = spec.pop('language') self.spec: Final = spec @@ -110,7 +110,7 @@ def name_to_alias(name: str) -> str: return name @staticmethod - def post_process_spec(spec: Dict[str, Any], options :Dict[str, Any]) -> None: + def post_process_spec(spec: Dict[str, Any], options: Dict[str, Any]) -> None: return None def __init__(self, **kwargs: Dict[str, Any]) -> None: diff --git a/tests/test_sphinx_spec.py b/tests/test_sphinx_spec.py index 0a12deb..12a0d5b 100644 --- a/tests/test_sphinx_spec.py +++ b/tests/test_sphinx_spec.py @@ -16,12 +16,22 @@ def test_spec_code() -> None: assert obj.filename == 'filename' assert obj.spec == {'caption': 'my_header', 'linenos': True} + obj = SpecCode.from_options({'hide_code': None}) + assert obj.hide is True + + obj = SpecCode.from_options({'hide': None}) + assert obj.hide is True + def test_spec_output() -> None: - obj = SpecOutput.from_options({'hide_output': True, 'caption_output': 'my_header_out'}) + obj = SpecOutput.from_options({'hide_output': None, 'caption_output': 'my_header_out'}) assert obj.hide is True assert obj.spec == {'caption': 'my_header_out'} + obj = SpecOutput.from_options({'caption_output': 'my_header_out'}) + assert obj.hide is False + assert obj.spec == {'caption': 'my_header_out'} + def test_invalid_options() -> None: with pytest.raises(ValueError) as e: # noqa: PT011