From bd124759434b3ea4999f78c86f9bdc3f95e7ec4a Mon Sep 17 00:00:00 2001 From: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:24:00 +0300 Subject: [PATCH 1/4] Add Renovate config and update package version placeholder Introduce a `renovate.json` file with a recommended configuration to manage dependencies. Updated `__init__.py` to include a placeholder comment for replacing the package name in the version call. Signed-off-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> --- my_pkg/__init__.py | 2 +- renovate.json | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 renovate.json diff --git a/my_pkg/__init__.py b/my_pkg/__init__.py index baaed07..44788d2 100644 --- a/my_pkg/__init__.py +++ b/my_pkg/__init__.py @@ -1,3 +1,3 @@ from importlib.metadata import version -__version__ = version("my-pkg") +__version__ = version("my-pkg") # todo: replace with your package name diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..c943a66 --- /dev/null +++ b/renovate.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended" + ], + "python": { + "lockFileMaintenance": { + "enabled": true + } + }, + "schedule": [ + "every day" + ], + "packageRules": [ + { + "matchManagers": ["uv"], + "groupName": false + + } + ] +} From 60059a6e8e91d5bc70f5590bb38510e872be917e Mon Sep 17 00:00:00 2001 From: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:29:27 +0300 Subject: [PATCH 2/4] Add tests for documentation examples and update linting config Introduce tests to validate code examples in the documentation using Sybil and pytest. Updated `pyproject.toml` to configure linting rules, including ignoring specific linting checks for test and docs directories. Signed-off-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> --- pyproject.toml | 6 ++++-- tests/docs/__init__.py | 0 tests/docs/test_docs.py | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/docs/__init__.py create mode 100644 tests/docs/test_docs.py diff --git a/pyproject.toml b/pyproject.toml index b66eb4c..7563bda 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,10 +65,12 @@ line-length = 120 include = ["pyproject.toml", "tests/**",] [tool.ruff.lint] -select = ["F", "B", "I", "F", "W", "E","A","N"] +select = ["F", "B", "I", "F", "W", "E","A","N","D"] fixable = ["ALL"] - +[tool.ruff.lint.per-file-ignores] +"tests/*" = ["D"] +"docs/*" = ["D"] [tool.ruff.lint.isort] combine-as-imports = true [tool.mypy] diff --git a/tests/docs/__init__.py b/tests/docs/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/docs/test_docs.py b/tests/docs/test_docs.py new file mode 100644 index 0000000..7a4f463 --- /dev/null +++ b/tests/docs/test_docs.py @@ -0,0 +1,41 @@ +from pathlib import Path + +import pytest +from sybil import Sybil +from sybil.parsers.codeblock import PythonCodeBlockParser +from sybil.parsers.doctest import DocTestParser + + +def collect_examples(folder_name): + docs_folder_path = Path(__file__).parent.parent.parent / "docs" / "source" + models_folder_path = docs_folder_path / folder_name + assert docs_folder_path.exists(), f"Docs path doesn't exist: {docs_folder_path.resolve()}" + + all_rst_files = list(docs_folder_path.glob("*.rst")) + all_rst_files.extend(list(models_folder_path.glob("*.rst"))) + print(f"Found {len(all_rst_files)} .rst files in docs folder.") + # Configure Sybil + sybil = Sybil( + parsers=[ + DocTestParser(), + PythonCodeBlockParser(), + ], + pattern="*.rst", + path=docs_folder_path.as_posix(), + ) + examples_list = [] + for f_path in all_rst_files: + document_ = sybil.parse(f_path) + + examples_ = list(document_) + examples_files = [e.path for e in examples_] + examples_start_lines = [e.start for e in examples_] + + examples_list.extend(zip(examples_files, examples_start_lines, examples_)) + # examples_list=[example for example in examples_] + return examples_list + + +@pytest.mark.parametrize("file_path, line, example", collect_examples("")) +def test_doc_examples(file_path, line, example): + example.evaluate() From 13e9166d1f1f07e59be891beaecc883053dcd5ca Mon Sep 17 00:00:00 2001 From: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:33:16 +0300 Subject: [PATCH 3/4] Update dependencies and improve formatting consistency Updated package constraints in `uv.lock` to refine Python version markers and adjusted dependencies like `sybil` and `sphinx`. Bumped `ruff-pre-commit` to v0.11.6 and improved code formatting, ensuring clarity in `pyproject.toml` and `.pre-commit-config.yaml`. Signed-off-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- pyproject.toml | 15 +++++++-------- uv.lock | 10 +++++----- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7412f89..66e0600 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: trailing-whitespace - id: no-commit-to-branch - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.5 + rev: v0.11.6 hooks: - id: ruff-format args: [ --preview, --config=pyproject.toml ] diff --git a/pyproject.toml b/pyproject.toml index 7563bda..2f484cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,9 +3,9 @@ name = "my-pkg" # todo: change to your package name dynamic = ["version"] description = "" authors = [ - {name = "DanielAvdar", email = "66269169+DanielAvdar@users.noreply.github.com"}, # todo: change to your name and email + { name = "DanielAvdar", email = "66269169+DanielAvdar@users.noreply.github.com" }, # todo: change to your name and email ] -license = {text = "MIT"} +license = { text = "MIT" } readme = "README.md" classifiers = [ "Programming Language :: Python :: 3", @@ -33,20 +33,19 @@ dev = [ "mypy==1.13.0", "pytest-parametrization>=2022", "ruff>=0.8.2", - + "sybil[pytest]", ] docs = [ - "sybil[pytest]", "sphinx>=8.2.0; python_version >= '3.11'", "sphinx>=7.0.0; python_version < '3.11'", "sphinx-rtd-theme>=3.0.2", ] [tool.hatch.build.targets.sdist] -only-include = ["my_pkg",] # todo: change to your package name +only-include = ["my_pkg", ] # todo: change to your package name source = "." [tool.hatch.build.targets.wheel] -only-include = ["my_pkg",] # todo: change to your package name +only-include = ["my_pkg", ] # todo: change to your package name source = "." @@ -62,10 +61,10 @@ source = "uv-dynamic-versioning" [tool.ruff] line-length = 120 -include = ["pyproject.toml", "tests/**",] +include = ["pyproject.toml", "tests/**", ] [tool.ruff.lint] -select = ["F", "B", "I", "F", "W", "E","A","N","D"] +select = ["F", "B", "I", "F", "W", "E", "A", "N", "D"] fixable = ["ALL"] [tool.ruff.lint.per-file-ignores] diff --git a/uv.lock b/uv.lock index 8bbafdb..1a5db80 100644 --- a/uv.lock +++ b/uv.lock @@ -1,10 +1,10 @@ version = 1 revision = 1 -requires-python = ">=3.9, <4" +requires-python = ">=3.9" resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version < '3.10'", - "python_full_version >= '3.11'", ] [[package]] @@ -24,8 +24,8 @@ name = "alabaster" version = "1.0.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ - "python_full_version == '3.10.*'", "python_full_version >= '3.11'", + "python_full_version == '3.10.*'", ] sdist = { url = "https://files.pythonhosted.org/packages/a6/f8/d9c74d0daf3f742840fd818d69cfae176fa332022fd44e3469487d5a9420/alabaster-1.0.0.tar.gz", hash = "sha256:c00dca57bca26fa62a6d7d0a9fcce65f3e026e9bfe33e9c538fd3fbb2144fd9e", size = 24210 } wheels = [ @@ -418,13 +418,13 @@ dev = [ { name = "pytest-cov" }, { name = "pytest-parametrization" }, { name = "ruff" }, + { name = "sybil", extra = ["pytest"] }, ] docs = [ { name = "sphinx", version = "7.4.7", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.10'" }, { name = "sphinx", version = "8.1.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.10.*'" }, { name = "sphinx", version = "8.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" }, { name = "sphinx-rtd-theme" }, - { name = "sybil", extra = ["pytest"] }, ] [package.metadata] @@ -439,12 +439,12 @@ dev = [ { name = "pytest-cov", specifier = ">=4.0.0" }, { name = "pytest-parametrization", specifier = ">=2022" }, { name = "ruff", specifier = ">=0.8.2" }, + { name = "sybil", extras = ["pytest"] }, ] docs = [ { name = "sphinx", marker = "python_full_version < '3.11'", specifier = ">=7.0.0" }, { name = "sphinx", marker = "python_full_version >= '3.11'", specifier = ">=8.2.0" }, { name = "sphinx-rtd-theme", specifier = ">=3.0.2" }, - { name = "sybil", extras = ["pytest"] }, ] [[package]] From 4e3a08251608c5a7d30e12908b5447deff0feabf Mon Sep 17 00:00:00 2001 From: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> Date: Wed, 23 Apr 2025 13:36:56 +0300 Subject: [PATCH 4/4] Add docstring to package __init__.py Introduce a placeholder docstring at the top of the __init__.py file. This serves as a placeholder for a proper package description to be updated later. Signed-off-by: DanielAvdar <66269169+DanielAvdar@users.noreply.github.com> --- my_pkg/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/my_pkg/__init__.py b/my_pkg/__init__.py index 44788d2..85345a9 100644 --- a/my_pkg/__init__.py +++ b/my_pkg/__init__.py @@ -1,3 +1,5 @@ +"""Demo init.""" # todo: change to package description. + from importlib.metadata import version __version__ = version("my-pkg") # todo: replace with your package name