Skip to content

Conversation

@chrimaho
Copy link

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
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
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.

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