-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply click-type-test to check CLI annotations
Using click-type-test, we can confirm that the parameter annotations are correct. Most of the annotations line up. The only things which needed special attention were `Literal` deductions from `click.Choice` parameters. A couple of the types are easily tripped up by some of the dynamism at play, so these are solved with `overrides` in the typing test. There's also an adjustment to fix a BinaryIO/IO[bytes] discrepancy, driven mostly to become consistent with the click type annotations.
- Loading branch information
Showing
10 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import typing as t | ||
|
||
import pytest | ||
|
||
from check_jsonschema.cli import main as cli_main | ||
|
||
click_type_test = pytest.importorskip( | ||
"click_type_test", reason="tests require 'click-type-test'" | ||
) | ||
|
||
|
||
def test_annotations_match_click_params(): | ||
click_type_test.check_param_annotations( | ||
cli_main, | ||
overrides={ | ||
# don't bother with a Literal for this, since it's relatively dynamic data | ||
"builtin_schema": str | None, | ||
# force default_filetype to be a Literal including `json5`, which is only | ||
# included in the choices if a parser is installed | ||
"default_filetype": t.Literal["json", "yaml", "toml", "json5"], | ||
}, | ||
) |