Add schema for docstring-format-checker#5309
Add schema for docstring-format-checker#5309hyperupcall merged 10 commits intoSchemaStore:masterfrom
docstring-format-checker#5309Conversation
- 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.
|
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.
|
Hi @hyperupcall, thanks for your message. 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 Which makes sense, because that is exactly what this PR is looking to add. Once merged, then Can you please confirm that this is expected behaviour? Thank you. |
|
@chrimaho This error is expected, please see |
- 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`.
|
This PR is stale because it has been open 60 days with no activity. Comment or this will be closed in 7 days. |
|
@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 |
|
Hi @hyperupcall, thank you for your advice 👍 I really appreciate it! |
|
Glad it's working! LGTM |
|
Sorry @hyperupcall, you don't have access to these files: |
This pull request adds support for validating configuration of the
docstring-format-checkertool inpyproject.tomlby introducing a new JSON schema and integrating it into the overallpyproject.jsonschema. The main focus is on enabling schema validation for both[tool.dfc]and[tool.docstring-format-checker]sections.Schema integration for docstring-format-checker:
partial-dfc.jsonthat defines configuration options for thedocstring-format-checkertool, including properties likeallow_undefined_sections,require_docstrings,check_private,validate_param_types,optional_style, and a detailedsectionsarray for custom docstring section validation.pyproject.jsonto reference the newpartial-dfc.jsonschema under bothdfcanddocstring-format-checkerkeys, allowing users to configure the tool using either[tool.dfc]or[tool.docstring-format-checker]in theirpyproject.toml.