Run pyright on components directory (#4948)

* apply pyright components

* Add code

* CHANGELOG

* format

* Add configuration

---------

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
Freddy Boulton 2023-07-18 12:31:53 -05:00 committed by GitHub
parent 181c6721b6
commit 5dba3b2217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 15 additions and 12 deletions

View File

@ -16,7 +16,7 @@ No changes to highlight.
## Other Changes: ## Other Changes:
No changes to highlight. - Apply pyright to the `components` directory by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 4948](https://github.com/gradio-app/gradio/pull/4948)
# Version 3.37 # Version 3.37

View File

@ -270,7 +270,6 @@ class BarPlot(Plot):
"bottom-right", "bottom-right",
"none", "none",
] ]
| None
| None = None, | None = None,
height: int | None = None, height: int | None = None,
width: int | None = None, width: int | None = None,
@ -366,7 +365,7 @@ class BarPlot(Plot):
x_title=self.x_title, x_title=self.x_title,
y_title=self.y_title, y_title=self.y_title,
color_legend_title=self.color_legend_title, color_legend_title=self.color_legend_title,
color_legend_position=self.color_legend_position, color_legend_position=self.color_legend_position, # type: ignore
group_title=self.group_title, group_title=self.group_title,
y_lim=self.y_lim, y_lim=self.y_lim,
interactive=self.interactive_chart, interactive=self.interactive_chart,

View File

@ -371,7 +371,7 @@ class IOComponent(Component):
class FormComponent: class FormComponent:
def get_expected_parent(self) -> type[Form]: def get_expected_parent(self) -> type[Form] | None:
if getattr(self, "container", None) is False: if getattr(self, "container", None) is False:
return None return None
return Form return Form

View File

@ -415,10 +415,10 @@ class LinePlot(Plot):
tooltip=self.tooltip, tooltip=self.tooltip,
x_title=self.x_title, x_title=self.x_title,
y_title=self.y_title, y_title=self.y_title,
color_legend_title=self.color_legend_title, color_legend_title=self.color_legend_title, # type: ignore
color_legend_position=self.color_legend_position, color_legend_position=self.color_legend_position, # type: ignore
stroke_dash_legend_title=self.stroke_dash_legend_title, stroke_dash_legend_title=self.stroke_dash_legend_title,
stroke_dash_legend_position=self.stroke_dash_legend_position, stroke_dash_legend_position=self.stroke_dash_legend_position, # type: ignore
x_lim=self.x_lim, x_lim=self.x_lim,
y_lim=self.y_lim, y_lim=self.y_lim,
stroke_dash=self.stroke_dash, stroke_dash=self.stroke_dash,

View File

@ -459,9 +459,9 @@ class ScatterPlot(Plot):
color_legend_title=self.color_legend_title, color_legend_title=self.color_legend_title,
size_legend_title=self.size_legend_title, size_legend_title=self.size_legend_title,
shape_legend_title=self.size_legend_title, shape_legend_title=self.size_legend_title,
color_legend_position=self.color_legend_position, color_legend_position=self.color_legend_position, # type: ignore
size_legend_position=self.size_legend_position, size_legend_position=self.size_legend_position, # type: ignore
shape_legend_position=self.shape_legend_position, shape_legend_position=self.shape_legend_position, # type: ignore
interactive=self.interactive_chart, interactive=self.interactive_chart,
height=self.height, height=self.height,
width=self.width, width=self.width,

View File

@ -359,7 +359,7 @@ class Video(
"orig_name": Path(video).name, "orig_name": Path(video).name,
} }
def _format_subtitle(self, subtitle: str | None) -> FileData | None: def _format_subtitle(self, subtitle: str | Path | None) -> FileData | None:
""" """
Convert subtitle format to VTT and process the video to ensure it meets the HTML5 requirements. Convert subtitle format to VTT and process the video to ensure it meets the HTML5 requirements.
Parameters: Parameters:

View File

@ -76,6 +76,10 @@ include = [
"/requirements.txt", "/requirements.txt",
] ]
[tool.pyright]
include = ["gradio/**/*.py"]
exclude = ["gradio/themes/"]
[tool.ruff] [tool.ruff]
target-version = "py37" target-version = "py37"
extend-select = [ extend-select = [

View File

@ -3,4 +3,4 @@ source scripts/helpers.sh
pip_required pip_required
python -m pyright gradio/*.py python -m pyright