Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add mypy schema #3422

Merged
merged 3 commits into from
Dec 20, 2023
Merged

Conversation

henryiii
Copy link
Contributor

@henryiii henryiii commented Dec 1, 2023

This adds a schema for mypy.

Signed-off-by: Henry Schreiner <[email protected]>
@hyperupcall
Copy link
Member

hyperupcall commented Dec 2, 2023

Thanks! I was wondering your thoughts on using the name unstable-internal-mypy.json?

There seems to be a common use case for schemas that are their own file, and only meant to be referenced/$ref'd in another schema. But, we don't explicitly state it, with code, naming, or otherwise, so I'm thinking we can prefix the name of these schemas with unstable-internal-

I think that this name would make it more obvious that the schema is an internal abstraction, solely to make editing schemas in this repository easier. For example, when IDEs prompt a user to explicitly select a JSON schema to use, they can potentially ignore entries that match ^unstable-internal since they will never apply to a whole file (checking for an empty fileMatch is not semantically correct, and will lead to false negatives). I also think it would be useful for these entries to be "alphabetically besides each other" on file system explorers and also the "unstable" name will make it clear not to use it, in case further refactoring or name changes is needed on our part.

@hyperupcall
Copy link
Member

(I saw your python/mypy#16601 PR, and I'm working on something similar with jsonschema-extractor, and I think deciding on an informal convention would be beneficial.)

@henryiii
Copy link
Contributor Author

henryiii commented Dec 2, 2023

Unstable sounds like it should not be used. It's actually very useful on its own; I'm using them with validate-pyproject (PR merged, but unreleased so far), which expects the schema to describe the tool section. validate-pyproject --tool mypy=https://json.schemastore.org/mypy.toml would load the mypy file and use it. As will validate-pyproject --tool cibuildwheel=https://json.schemastore.org/cibuildwheel.toml#/properties/tool/properties, etc. What about pyproject-mypy.json? Though some of these are useful on their own; ruff and cibuildwheel work directly on lone configuration files, and even mypy would if you could validate .ini files (they don't have a standalone toml file format, at least currently), etc. I would assume other "nested" schemas could follow a similar pattern.

Possible "partial-pyproject-mypy.json" or "internal-pyproject-mypy.json". I don't mind the "internal", but not fond of the "unstable".

(I'm working on a followup that will load all ref'd schemas in a "store" file (the pyproject.toml one), so the names won't actually be all that exposed soon.)

Validate-pyproject PRs:

@hyperupcall
Copy link
Member

hyperupcall commented Dec 2, 2023

I see - yeah on second thought, neither 'unstable' or 'internal' are not good names for most of these schemas. I didn't think that some validators could use our URLs to explicitly validate a subschema. The name pyproject-mypy.json sounds good, but I'm thinking it still could be better. Like you mention, ruff and cibuildwheel can be their own file (even if not JSON). And, pyproject-mypy could imply that 'mypy' is somehow dependent on 'pyproject'.

How about this:

  • If a schema represents an existing project, that could be its own file (even if INI), then keep the name the same (what is already done)
  • If the schema cannot be its own file, I like your idea of prefixing with partial- (partial-mypy.json). If later the project supports a stanadlone config file, we can always $ref the partial.

@henryiii
Copy link
Contributor Author

henryiii commented Dec 2, 2023

Are you suggesting partial-mypy.json or partial-pyproject-mypy.json?

@hyperupcall
Copy link
Member

I was a bit vague - partial-mypy.json

@henryiii
Copy link
Contributor Author

henryiii commented Dec 2, 2023

And are you suggesting we change poetry, scikit-build, and setuptools? (hatch, cibuildwheel, and ruff all also can stand alone). (In a later PR, of course)

@hyperupcall
Copy link
Member

hyperupcall commented Dec 2, 2023

I do have a slight preference to rename those instances in a backwards-compatible way. For example, renaming poetry.json to partial-poetry.json, and creating a new poetry.json with a $ref to partial-poetry.json. But I don't think it's all that necessary.

If you'd like, I can make the PR doing this. If you aren't in favor, then we can keep poetry skikit-build and setuptools as they are, without changes.

Co-authored-by: Henry Schreiner <[email protected]>
@hyperupcall hyperupcall merged commit 683991d into SchemaStore:master Dec 20, 2023
3 checks passed
@hyperupcall
Copy link
Member

thanks!

@bersbersbers
Copy link

Hi, this is great! I am getting two error messages in my pyproject.toml now (VS Code with Even Better TOML):

Additional properties are not allowed ('show_error_codes', 'show_error_code_links' were unexpected)

image

Some infos on those:

@hyperupcall
Copy link
Member

@bersbersbers thanks for the report, I have created issue #3467 to track it

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.

4 participants