Closed stdedos closed 1 year ago
More details about the changes:
The "main" schema is written in schema.yaml
. The schema.json
and schema.md
are supportive files:
schema.json
is needed, because it is read by the editors - and not the YAML fileschema.md
is optional for documentation purposes (it is in a more readable format).
It is generated via jsonschema2md
- but there some small improvements needed (at least https://github.com/stdedos/jsonschema2md/tree/fix/align-multiline-description_0.9)The files can be generated, from the repo root:
(
set -e
cd pytest_mypy_plugins
yq -o=json schema.yaml >| schema.json
jsonschema2md schema.json schema.md --examples-as-yaml
)
I haven't seen any kind of "repo/release automation" setup, so I have avoided adding those commands. Also, two external tools are required for this, so ... some extra thinking might be needed. I'd recommend pre-commit
and custom hooks - but, up to you.
After that, you can do this:
... or, if you'd like more ✨ magic ✨ , then you can deploy it to SchemaStore (https://github.com/SchemaStore/schemastore/blob/2991ef67756c3bacfaa1bcb490c08922c13ca3f1/src/api/json/catalog.json#L1835-L1840) - but you'd have to "force-rename" the yml files to be picked-up automatically (e.g.,test_*.mypy.yaml
?)
... the only thing that bothers me is that we have 3 different schema files :)
Well ... we really have one. schema.yaml
.
Can we just use
schema.json
for now?
Well ... yes 😢 But it will make me SO MUCH MORE SAD writing it 😭
Or
yaml
one?
The yaml
file "cannot be used" with anything else. It's called JSONSchema 😉
I think that yaml
is a superset of json
. So, can't we just load yaml
file and convert it to json
in python?
This way we can at least try to have a single file for IDE-schema and validation.
I think that
yaml
is a superset ofjson
. So, can't we just loadyaml
file and convert it tojson
in python?
You can do that for https://github.com/typeddjango/pytest-mypy-plugins' validation. "IDE schema.json readers" fetch a JSON-file.
I could've, instead, avoided the load here https://github.com/typeddjango/pytest-mypy-plugins/pull/127/files#diff-f3f061be87eac60afb6957b8b8ea08b948ca1a2b12b7584f99c7611adba6232aR33 and just give "directly" the JSON file.
But then you'd have "two dependencies": yaml
being the nice prototype (which you are not shipping anywhere), and the json
file (which you need to remember to "change it" every time you do changes on yaml
file - which, right now, they are not formally verified to match)
@stdedos yes, I think that this is good thing to start with: just one json
file :)
Later we can add more if needed.
Ok 🤷
GitHub does not understand this for some reason :)
If you start the
if you'd like more ✨ magic ✨ , then you can deploy it to SchemaStore (SchemaStore/schemastore@2991ef6/src/api/json/catalog.json#L1835-L1840) - but you'd have to "force-rename" the yml files to be picked-up automatically (e.g.,test_*.mypy.yaml?)
process, lemme know (and/or add it on your README.md)
I am not sure that I understand what that is :)
You can ask https://github.com/SchemaStore/schemastore/ to include your schema in their database, so that editors pick it up automagically.
However, that means you'd have to suggest to people to name their files "more specifically", so that a glob pattern configures it automatically. They can always manually type the comment above, if they don't want to rename their tests.
Create a
schema.yaml
to:Use said schema to meta-test all test files for conformance.
Additionally:
mypy_config
type tostr | None
jinja2.defaults.VARIABLE_START_STRING
to the more-correct_rendering_env.variable_start_string
..gitignore
This fixes the real issue behind https://github.com/typeddjango/pytest-mypy-plugins/pull/124: The problem was not that
mypy_config
MUST HAVE{{
whenparametrized
was set; It was passing alist
(ofdict
s) - which that was not templatable.Signed-off-by: Stavros Ntentos 133706+stdedos@users.noreply.github.com