Skip to content

Add schema for docstring-format-checker#5309

Merged
hyperupcall merged 10 commits intoSchemaStore:masterfrom
data-science-extensions:master
Apr 18, 2026
Merged

Add schema for docstring-format-checker#5309
hyperupcall merged 10 commits intoSchemaStore:masterfrom
data-science-extensions:master

Conversation

@chrimaho
Copy link
Copy Markdown
Contributor

This pull request adds support for validating configuration of the docstring-format-checker tool in pyproject.toml by introducing a new JSON schema and integrating it into the overall pyproject.json schema. The main focus is on enabling schema validation for both [tool.dfc] and [tool.docstring-format-checker] sections.

Schema integration for docstring-format-checker:

  • Added a new schema file partial-dfc.json that defines configuration options for the docstring-format-checker tool, including properties like allow_undefined_sections, require_docstrings, check_private, validate_param_types, optional_style, and a detailed sections array for custom docstring section validation.
  • Updated pyproject.json to reference the new partial-dfc.json schema under both dfc and docstring-format-checker keys, allowing users to configure the tool using either [tool.dfc] or [tool.docstring-format-checker] in their pyproject.toml.

- Introduce `partial-dfc.json` schema for the `docstring-format-checker` package.
- Reference the new schema in `pyproject.json` under `dfc` and `docstring-format-checker`.
- Provide detailed properties for configuration options in the schema.
@hyperupcall
Copy link
Copy Markdown
Member

Thanks! I can merge this once CI goes green;

- Improve formatting and readability of the JSON schema.
- Correct indentation.
- Introduce schema for `docstring-format-checker` with description and URL.
- Introduce schema for `dfc` with description and URL.
- Resolving failing `ajv` validation checks:
    - Error message:
    - `strict mode: use allowUnionTypes to allow union type keyword at "https://json.schemastore.org/partial-dfc.json#/properties/sections/items/properties/admonition" (strictTypes)`
- This means Ajv validation doesn't allow union types (e.g., `"type": ["boolean", "string"]`) by default under strict mode.
- Solution: Replace the union type definition for the "admonition" property with a `oneOf` clause.
- Here, the solution provides one of `"boolean"` with only the `false` value, or `"string"` otherwise.
@chrimaho
Copy link
Copy Markdown
Contributor Author

Hi @hyperupcall, thanks for your message.
I have resolved most of the errors. Please check.

The one that is remaining is the 'Ajv' check, which returns:

Running "Ajv validation" on file "./src/schemas/json/pyproject.json"
✖ 
---
>> Failed to compile schema file "./src/schemas/json/pyproject.json"
---
Error: can't resolve reference https://json.schemastore.org/partial-dfc.json from id https://json.schemastore.org/pyproject.json
    at Object.code (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/vocabularies/core/ref.js:21:19)
    at keywordCode (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:464:13)
    at /home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:185:25
    at CodeGen.code (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/codegen/index.js:439:13)
    at CodeGen.block (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/codegen/index.js:568:18)
    at schemaKeywords (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:185:13)
    at typeAndKeywords (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:128:5)
    at subSchemaObjCode (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:115:5)
    at subschemaCode (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:91:13)
    at KeywordCxt.subschema (/home/runner/work/schemastore/schemastore/node_modules/ajv/dist/compile/validate/index.js:438:9)
Error: Process completed with exit code 1.

It looks like the job is failing because the schema file pyproject.json references https://json.schemastore.org/partial-dfc.json, which cannot be resolved. To be specific: the schema reference does not exist.

Which makes sense, because that is exactly what this PR is looking to add. Once merged, then schemastore would be creating this record file. Right?

Can you please confirm that this is expected behaviour?

Thank you.

@hyperupcall
Copy link
Copy Markdown
Member

hyperupcall commented Feb 5, 2026

@chrimaho This error is expected, please see CONTRIBUTING.md for details on how to add a schema that is being $refed by another schema;

- Introduce schema entries for `dfc` and `docstring-format-checker` in the catalog.
- Reorder entries for `docstring-format-checker` and `dfc`.
- Add `partial-dfc.json` to the schema validation file match list.
- Create a new configuration file for `docstring-format-checker`.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

This PR is stale because it has been open 60 days with no activity. Comment or this will be closed in 7 days.

@github-actions github-actions Bot added the Stale PR is stale and will be closed in 7 days(auto-generated by stale action) label Apr 9, 2026
@hyperupcall
Copy link
Copy Markdown
Member

@chrimaho I tried pushing a fix to this feature branch, but it was blocked. You'd want make changes like the following:

diff --git a/src/api/json/catalog.json b/src/api/json/catalog.json
index cce5ece7..024cef3a 100644
--- a/src/api/json/catalog.json
+++ b/src/api/json/catalog.json
@@ -1607,18 +1607,7 @@
       "fileMatch": ["devbox-plugin.json"],
       "url": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox-plugin.schema.json"
     },
-    {
-      "name": "dfc",
-      "description": "A CLI tool to check and validate Python docstring formatting and completeness",
-      "fileMatch": [],
-      "url": "https://json.schemastore.org/partial-dfc.json"
-    },
-    {
-      "name": "docstring-format-checker",
-      "description": "A CLI tool to check and validate Python docstring formatting and completeness",
-      "fileMatch": [],
-      "url": "https://json.schemastore.org/partial-dfc.json"
-    },
+
     {
       "name": "Drupal Breakpoints",
       "description": "Drupal configuration for breakpoints",
diff --git a/src/schema-validation.jsonc b/src/schema-validation.jsonc
index e6147a4f..e4c52466 100644
--- a/src/schema-validation.jsonc
+++ b/src/schema-validation.jsonc
@@ -318,6 +318,7 @@
     "partial-setuptools-scm.json", // pyproject.json[tool.setuptools-scm]
     "partial-scikit-build.json", // pyproject.json[tool.scikit-build]
     "partial-cibuildwheel.json", // pyproject.json[tool.cibuildwheel]
+    "partial-dfc.json", // pyproject.json[tool.dfc]
     "partial-mypy.json", // pyproject.json[tool.mypy]
     "partial-pdm.json", // pyproject.json[tool.pdm]
     "partial-pdm-dockerize.json", // pyproject.json[tool.pdm.dockerize]
diff --git a/src/test/pyproject/dfc.toml b/src/test/pyproject/dfc.toml
new file mode 100644
index 00000000..5711e0c7
--- /dev/null
+++ b/src/test/pyproject/dfc.toml
@@ -0,0 +1,36 @@
+#:schema ../../schemas/json/pyproject.json
+[tool.dfc]
+allow_undefined_sections = true
+require_docstrings = true
+check_private = false
+validate_param_types = true
+optional_style = "validate"
+
+[[tool.dfc.sections]]
+name = "Args"
+type = "list_name_and_type"
+order = 1
+admonition = false
+required = true
+
+[[tool.dfc.sections]]
+name = "Returns"
+type = "list_type"
+order = 2
+admonition = "note"
+prefix = "Return value:"
+required = false
+message = "Missing returns section"
+
+[[tool.dfc.sections]]
+name = "Raises"
+type = "list_name"
+order = 3
+required = false
+
+[[tool.dfc.sections]]
+name = "Examples"
+type = "free_text"
+order = 4
+admonition = "example"
+required = false
\ No newline at end of file
diff --git a/src/test/pyproject/docstring-format-checker.toml b/src/test/pyproject/docstring-format-checker.toml
new file mode 100644
index 00000000..6a695b70
--- /dev/null
+++ b/src/test/pyproject/docstring-format-checker.toml
@@ -0,0 +1,41 @@
+#:schema ../../schemas/json/pyproject.json
+[tool.docstring-format-checker]
+allow_undefined_sections = false
+require_docstrings = true
+check_private = true
+validate_param_types = true
+optional_style = "strict"
+
+[[tool.docstring-format-checker.sections]]
+name = "Parameters"
+type = "list_name_and_type"
+order = 1
+required = true
+admonition = false
+
+[[tool.docstring-format-checker.sections]]
+name = "Returns"
+type = "list_type"
+order = 2
+required = true
+admonition = "info"
+prefix = "Returns:"
+message = "Return type documentation is required"
+
+[[tool.docstring-format-checker.sections]]
+name = "Raises"
+type = "list_name"
+order = 3
+required = false
+
+[[tool.docstring-format-checker.sections]]
+name = "Yields"
+type = "list_type"
+order = 4
+required = false
+
+[[tool.docstring-format-checker.sections]]
+name = "Note"
+type = "free_text"
+admonition = "note"
+required = false
\ No newline at end of file

@github-actions github-actions Bot removed the Stale PR is stale and will be closed in 7 days(auto-generated by stale action) label Apr 12, 2026
@chrimaho
Copy link
Copy Markdown
Contributor Author

Hi @hyperupcall, thank you for your advice 👍 I really appreciate it!
I've added these changes now, and all checks are passing.
Can you please review it?

@hyperupcall
Copy link
Copy Markdown
Member

Glad it's working! LGTM

@hyperupcall hyperupcall merged commit 76eb19f into SchemaStore:master Apr 18, 2026
4 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

Sorry @hyperupcall, you don't have access to these files:

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.

2 participants