Skip to content

Commit

Permalink
🔧 Added pyright
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilbadyal committed Sep 28, 2023
1 parent 7b39248 commit 1a76dcb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
17 changes: 4 additions & 13 deletions esxport/click_opt/click_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import TYPE_CHECKING, Any

from click import Context, Parameter, ParamType
from click_params.miscellaneous import JsonParamType

from esxport.strings import invalid_query_format, invalid_sort_format

Expand Down Expand Up @@ -45,24 +44,16 @@ def convert(self: Self, value: Any, param: Parameter | None, ctx: Context | None
sort = Sort()


class Json(JsonParamType): # type: ignore[misc]
class Json(ParamType):
"""Json Validator."""

name = "json"

def convert(self: Self, value: Any, param: Parameter, ctx: Context) -> dict[str, Any]: # type: ignore[return]
def convert(self: Self, value: Any, param: Parameter | None, ctx: Context | None) -> dict[str, Any]:
"""Convert input to json."""
try:
return json.loads( # type: ignore[no-any-return]
value,
cls=self._cls,
object_hook=self._object_hook,
parse_float=self._parse_float,
parse_int=self._parse_int,
parse_constant=self._parse_constant,
object_pairs_hook=self._object_pairs_hook,
**self._kwargs,
)
return json.loads(value) # type: ignore[no-any-return]

except json.JSONDecodeError as exc:
self.fail(invalid_query_format.format(value=value, exc=exc), param, ctx)

Expand Down
2 changes: 1 addition & 1 deletion esxport/esxport.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def next_scroll(self: Self, scroll_id: str) -> Any:

def _write_to_temp_file(self: Self, res: Any) -> None:
"""Write to temp file."""
hit_list = []
hit_list: list[dict[str, Any]] = []
total_size = int(min(self.opts.max_results, self.num_results))
bar = tqdm(
desc=f"{self.opts.output_file}.tmp",
Expand Down
8 changes: 8 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,11 @@ exclude_lines = [
'if TYPE_CHECKING:',
'if __name__ == "__main__":'
]



[tool.pyright]
include = ["."]
typeCheckingMode = "strict"
exclude = ["**/test",]
reportMissingTypeStubs = false

0 comments on commit 1a76dcb

Please sign in to comment.