Skip to content
Merged

0.16 #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/sphinx_exec_code/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.15'
__version__ = '0.16'
4 changes: 2 additions & 2 deletions src/sphinx_exec_code/sphinx_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_FLAG>') is None
self.language: Final = spec.pop('language')
self.spec: Final = spec

Expand Down Expand Up @@ -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:
Expand Down
12 changes: 11 additions & 1 deletion tests/test_sphinx_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down