Skip to content

Commit

Permalink
Update dependencies (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
provinzkraut authored Aug 18, 2024
1 parent 8cad31e commit 75ab4cf
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 106 deletions.
30 changes: 27 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,30 @@ jobs:
- name: Install dependencies
run: poetry install
- name: Run tests
run: |
source $VENV
pytest
run: poetry run pytest

mypy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
installer-parallel: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-ubuntu-latest-3.8-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
- name: Run mypy
run: poetry run mypy
24 changes: 4 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ repos:
- id: check-yaml
- id: end-of-file-fixer
exclude: "_test_data"
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.260'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
hooks:
- id: ruff
args: ["--fix"]
exclude: test/sphinx_ext_test_data/example.py
args: [ --fix ]
- id: ruff-format
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.16
hooks:
Expand All @@ -23,15 +19,3 @@ repos:
args: ["--number"]
additional_dependencies:
- mdformat-gfm
- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.1.1"
hooks:
- id: mypy
exclude: "test"
args: ["--strict"]
additional_dependencies:
- "types-docutils==0.19.1.1"
- "sphinx==5.3.0"
- types-markdown
- "mkdocs==1.4.2"
- pymdown-extensions
4 changes: 1 addition & 3 deletions auto_pytabs/markdown_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ def _convert_block(
else:
code = "\n".join([head, versioned_code[versions[0]], tail])

code = _add_indentation(code, indentation)

return code
return _add_indentation(code, indentation)


class UpgradePreprocessor(Preprocessor):
Expand Down
4 changes: 2 additions & 2 deletions auto_pytabs/mkdocs_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AutoPyTabsPlugin(BasePlugin[PluginConfig]): # type: ignore[no-untyped-cal
def __init__(self) -> None:
self.cache: Cache | None = None

def on_config(self, config: MkDocsConfig) -> Config | None:
def on_config(self, config: MkDocsConfig) -> MkDocsConfig | None:
if not self.config.no_cache:
self.cache = Cache()

Expand All @@ -42,7 +42,7 @@ def on_config(self, config: MkDocsConfig) -> Config | None:
}
}
)
return None
return config

def on_post_build(self, config: MkDocsConfig) -> None:
if self.cache:
Expand Down
21 changes: 11 additions & 10 deletions auto_pytabs/sphinx_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import importlib
import importlib.metadata
from collections.abc import Iterable
from typing import TYPE_CHECKING, Any, Literal, cast
from typing import TYPE_CHECKING, Any, Literal

from docutils.nodes import Node, container, section
from docutils.parsers.rst import directives
from docutils.statemachine import ViewList
from docutils.statemachine import StringList
from sphinx.directives.code import CodeBlock, LiteralInclude
from sphinx.util.docutils import SphinxDirective
from sphinx.util.nodes import nested_parse_with_titles
Expand Down Expand Up @@ -64,7 +64,7 @@ def _get_directive_options(self) -> dict[str, Any]:
for option, value in self.options.items():
if option not in CodeBlock.option_spec:
continue
if self.option_spec[option] is directives.flag:
if self.option_spec and self.option_spec[option] is directives.flag:
value = True
if isinstance(value, Iterable) and not isinstance(value, str):
value = "\n".join(value)
Expand Down Expand Up @@ -129,7 +129,7 @@ def _create_py_tab_nodes(self, code: str) -> list[Node]:
versioned_code, self.env.config["auto_pytabs_tab_title_template"]
)

rst = ViewList()
rst = StringList()
source, lineno = self.get_source_info()
for line in tabs:
rst.append(line, source, lineno)
Expand All @@ -138,9 +138,7 @@ def _create_py_tab_nodes(self, code: str) -> list[Node]:
node.document = self.state.document

nested_parse_with_titles(self.state, rst, node)
nodes = node.children

return cast("list[Node]", nodes)
return node.children


class PyTabsCodeBlock(CodeBlock, UpgradeMixin):
Expand All @@ -163,12 +161,12 @@ def run(self) -> list[Node]:
return [base_node]
if isinstance(base_node, container):
base_node = base_node.children[1]
return self._create_py_tab_nodes(base_node.rawsource) # type: ignore[attr-defined] # noqa: E501
return self._create_py_tab_nodes(base_node.rawsource) # type: ignore[attr-defined]


class CodeBlockOverride(PyTabsCodeBlock):
compat = False
option_spec = {**CodeBlock.option_spec, "no-upgrade": directives.flag}
option_spec = {**CodeBlock.option_spec, "no-upgrade": directives.flag} # type: ignore[misc] # noqa: RUF012

def run(self) -> list[Node]:
if "no-upgrade" in self.options:
Expand All @@ -179,7 +177,10 @@ def run(self) -> list[Node]:

class LiteralIncludeOverride(PyTabsLiteralInclude):
compat = False
option_spec = {**LiteralInclude.option_spec, "no-upgrade": directives.flag}
option_spec = { # type: ignore[misc] # noqa: RUF012
**LiteralInclude.option_spec,
"no-upgrade": directives.flag,
}

def run(self) -> list[Node]:
if "no-upgrade" in self.options:
Expand Down
104 changes: 52 additions & 52 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 16 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ mkdocs = {version = ">=1.4.2,<2", optional = true}

[tool.poetry.group.dev.dependencies]
black = "^22.10.0"
mypy = "^0.990"
types-markdown = "^3.4.2.1"
pytest = "^7.2.0"
pymdown-extensions = "^9.9"
mypy = "^1.11.1"
types-markdown = "^3.6.0.20240316"
pytest = "^8.3.2"
pymdown-extensions = "^10.9"
sphinx-design = "^0.3.0"
pytest-regressions = "^2.4.2"
types-docutils = "^0.19.1.1"
mkdocs = "^1.4.2"
pyyaml = "^6.0"
pytest-mock = "^3.10.0"
pytest-regressions = "^2.5.0"
types-docutils = "^0.21.0.20240724"
mkdocs = "^1.6.0"
pyyaml = "^6.0.2"
pytest-mock = "^3.14.0"
pre-commit = "^3.2.1"


Expand All @@ -48,6 +48,7 @@ build-backend = "poetry.core.masonry.api"

[tool.mypy]
strict = true
files = ["auto_pytabs"]


[tool.pytest.ini_options]
Expand All @@ -57,8 +58,12 @@ filterwarnings = [
"ignore::DeprecationWarning:importlib.resources._legacy:80",
]


[tool.ruff]
src = ["auto_pytabs", "test"]
target-version = "py38"
exclude = ["test/sphinx_ext_test_data/example.py"]

[tool.ruff.lint]
select = [
"DTZ", # flake8-datetimez
"E", # pycodestyle errors
Expand All @@ -81,9 +86,6 @@ select = [
"YTT", # flake8-2020
]

src = ["auto_pytabs", "test"]
target-version = "py38"


[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"test*" = ["S101"]
Loading

0 comments on commit 75ab4cf

Please sign in to comment.