Skip to content

docs: add missing docstrings#82

Merged
PascalRepond merged 1 commit intorero:stagingfrom
PascalRepond:rep-ruff
Mar 31, 2026
Merged

docs: add missing docstrings#82
PascalRepond merged 1 commit intorero:stagingfrom
PascalRepond:rep-ruff

Conversation

@PascalRepond
Copy link
Copy Markdown
Contributor

@PascalRepond PascalRepond commented Mar 30, 2026

  • Add more ruff lint rules and fix linting errors.
  • Update pygments to 2.20.0 to fix GHSA-5239-wwwm-4pmq.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dfc4e6c9-1528-4373-910d-196123bffab6

📥 Commits

Reviewing files that changed from the base of the PR and between d99f9d5 and 6f7f649.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • flask_wiki/__init__.py
  • flask_wiki/api.py
  • flask_wiki/forms.py
  • flask_wiki/markdown_ext.py
  • flask_wiki/utils.py
  • flask_wiki/views.py
  • pyproject.toml
  • scripts/test
  • tests/conftest.py
💤 Files with no reviewable changes (1)
  • scripts/test
✅ Files skipped from review due to trivial changes (4)
  • flask_wiki/init.py
  • flask_wiki/utils.py
  • flask_wiki/forms.py
  • flask_wiki/markdown_ext.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • pyproject.toml
  • flask_wiki/views.py
  • flask_wiki/api.py

Walkthrough

Refactors filesystem handling to pathlib across core modules, makes two method arguments keyword-only, broadens Ruff linting with per-file ignores, removes a pip-audit CVE suppression, updates regex flag names, adjusts pytest fixtures, and expands/docstrings and copyright year ranges. No public API removals.

Changes

Cohort / File(s) Summary
API & core wiki logic
flask_wiki/api.py
Replaced os/open/stat/remove/rename logic with pathlib.Path variants, added traversal guard using Path.resolve().is_relative_to(), changed Page.__init__ and Page.save to require keyword-only args, updated index/delete/move/list/save/load/render to use Path APIs, and expanded docstrings.
Views & request handling
flask_wiki/views.py
Switched filesystem and glob handling to pathlib.Path, built language paths with f-strings, used Path.unlink() and Path.is_file(), changed exception catching to OSError, updated uploaded file enumeration to Path.glob() + stat().st_mtime, and adjusted some docstrings and handler param names.
Markdown extension
flask_wiki/markdown_ext.py
Replaced placeholder docstrings with descriptive ones, adjusted lint suppression comment to # noqa: N802, and updated extendMarkdown docstring to document processor registration.
Utilities & forms
flask_wiki/utils.py, flask_wiki/forms.py, flask_wiki/__init__.py
Changed regex flags from `re.X
Packaging / lint config
pyproject.toml
Switched ruff config to extend-select = ["ALL"], added global ignores for COM812/ANN, and added per-file ignores for examples/*, tests/*, and tests/conftest.py.
Scripts & CI helpers
scripts/test
Removed explicit addition of a pip-audit exception for CVE-2026-4539 so pip-audit runs without that suppression.
Tests / fixtures
tests/conftest.py
Converted a generator-style fixture (yield app) to return app, changed @pytest.fixture() to @pytest.fixture on two fixtures, and updated header copyright.
Misc (docs/headers)
various files (flask_wiki/markdown_ext.py, flask_wiki/forms.py, flask_wiki/__init__.py, ...)
Multiple docstring expansions and copyright year updates across package files; no behavioral changes beyond items above.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'docs: add missing docstrings' is partially related to the changeset. While the PR does add docstrings, this is only one aspect of a much broader set of changes including code refactoring, linting rule updates, dependency updates, and build script modifications.
Description check ✅ Passed The description mentions adding ruff lint rules and fixing linting errors, and updating pygments, which are core elements of the changeset. However, it does not capture the substantial code refactoring work (pathlib migration, parameter changes) that constitutes a significant portion of the changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pyproject.toml`:
- Line 47: Ruff is reading ruff.toml first so the preview setting in
pyproject.toml is ignored; open ruff.toml and add preview = true under the
[lint] section (i.e., add or update the [lint] table to include preview = true)
so Ruff's preview rules are enabled instead of relying on preview = true in
pyproject.toml.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 51bf5f00-f0d9-4ac1-9d80-0d5d03aa7f18

📥 Commits

Reviewing files that changed from the base of the PR and between d00364e and 36a9a54.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • flask_wiki/markdown_ext.py
  • flask_wiki/utils.py
  • flask_wiki/views.py
  • pyproject.toml
  • scripts/test
💤 Files with no reviewable changes (1)
  • scripts/test

Comment thread pyproject.toml Outdated
@PascalRepond PascalRepond changed the title build: activate ruff preview rules docs: add missing docstrings Mar 30, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
flask_wiki/api.py (1)

392-407: ⚠️ Potential issue | 🔴 Critical

Bug: delete_by_term references non-existent schema field.

The schema (lines 413-419) defines fields url, title, tags, body, language — there is no path field. This call silently fails to remove the document from the search index.

🐛 Proposed fix
     def delete(self, url):
         """Delete a page and remove it from the search index.

         :param str url: URL slug of the page to delete
         :returns: True if deleted, False if the page did not exist
         :rtype: bool
         """
         path = self.path(url)
         if not self.exists(url):
             return False
         path.unlink()
         index_dir = index.open_dir(current_app.config.get("WIKI_INDEX_DIR"))
         writer = AsyncWriter(index_dir)
-        writer.delete_by_term("path", path)
+        writer.delete_by_term("url", url)
         writer.commit()
         return True
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flask_wiki/api.py` around lines 392 - 407, The delete method is calling
writer.delete_by_term("path", path) but the search schema has no "path" field,
so the document is never removed; update the call in delete(self, url) to delete
by the correct indexed field ("url") and pass the URL slug (the url parameter as
a string) rather than the Path object (path). Locate the delete method and
replace the delete_by_term invocation to use ("url", url) so the index removal
matches the schema and actually deletes the document from the search index.
🧹 Nitpick comments (1)
flask_wiki/api.py (1)

420-422: Minor: Redundant Path instantiation.

Path(index_dir) is instantiated twice on consecutive lines. Consider reusing a single variable.

♻️ Suggested refactor
-        if not Path(index_dir).exists():
-            Path(index_dir).mkdir()
+        index_path = Path(index_dir)
+        if not index_path.exists():
+            index_path.mkdir()
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@flask_wiki/api.py` around lines 420 - 422, Create a single Path instance for
index_dir and reuse it instead of calling Path(index_dir) twice: assign
Path(index_dir) to a variable (e.g., index_path), use index_path.exists() and
index_path.mkdir() and then pass index_dir (or index_path) to index.create_in as
appropriate; this eliminates redundant Path instantiation while preserving the
existing behavior in the block that creates the index.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@flask_wiki/api.py`:
- Around line 392-407: The delete method is calling
writer.delete_by_term("path", path) but the search schema has no "path" field,
so the document is never removed; update the call in delete(self, url) to delete
by the correct indexed field ("url") and pass the URL slug (the url parameter as
a string) rather than the Path object (path). Locate the delete method and
replace the delete_by_term invocation to use ("url", url) so the index removal
matches the schema and actually deletes the document from the search index.

---

Nitpick comments:
In `@flask_wiki/api.py`:
- Around line 420-422: Create a single Path instance for index_dir and reuse it
instead of calling Path(index_dir) twice: assign Path(index_dir) to a variable
(e.g., index_path), use index_path.exists() and index_path.mkdir() and then pass
index_dir (or index_path) to index.create_in as appropriate; this eliminates
redundant Path instantiation while preserving the existing behavior in the block
that creates the index.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e40f69f-c4e7-47ac-8bd9-f56e93eefac2

📥 Commits

Reviewing files that changed from the base of the PR and between 36a9a54 and d99f9d5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • flask_wiki/__init__.py
  • flask_wiki/api.py
  • flask_wiki/forms.py
  • flask_wiki/markdown_ext.py
  • flask_wiki/utils.py
  • flask_wiki/views.py
  • pyproject.toml
  • scripts/test
  • tests/conftest.py
💤 Files with no reviewable changes (1)
  • scripts/test
✅ Files skipped from review due to trivial changes (5)
  • tests/conftest.py
  • flask_wiki/forms.py
  • flask_wiki/utils.py
  • flask_wiki/markdown_ext.py
  • flask_wiki/init.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • pyproject.toml

- Add more ruff lint rules and fix linting errors.
- Update pygments to 2.20.0 to fix CVE-2026-4539.

Co-Authored-by: Pascal Repond <pascal.repond@rero.ch>
@PascalRepond PascalRepond requested review from jma and rerowep March 30, 2026 09:41
@PascalRepond PascalRepond merged commit 94a36e2 into rero:staging Mar 31, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant