Skip to content

Enforcing typing in blocks.py and context.py #2887

Merged
abidlabs merged 40 commits into
mainfrom
refactor-pathlib
Dec 27, 2022
Merged

Enforcing typing in blocks.py and context.py #2887
abidlabs merged 40 commits into
mainfrom
refactor-pathlib

Conversation

@abidlabs
Copy link
Copy Markdown
Member

@abidlabs abidlabs commented Dec 26, 2022

Fixing typing issues (#2832) and path-related refactoring (#2831) for the following files:

  • blocks.py
  • context.py

Adding typing has already discovered some bugs, such as a function that would raise False in place of return False!

Adds pyright to the CircleCI workflow to enforce typing in these two files. I used pyright because it was working more reliably than mypy for me in WSL and because it is already integrated into VSCode using the Pylance extension

Before (blocks.py):

image

After:

image

I had to touch other files in some cases to fix typing as it related to one of the two files above, but those other files are not fully correctly-typed yet. Also renamed queue.py to queuing.py and dataclasses.py to datacls.py because queue and dataclasses are built-in modules in Python, which was confusing the type checker

@github-actions
Copy link
Copy Markdown
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2887-all-demos

@abidlabs abidlabs changed the title Adding typing to blocks.py, components.py, and context.py Adding typing to blocks.py and context.py Dec 27, 2022
@abidlabs abidlabs changed the title Adding typing to blocks.py and context.py Enforcing typing in blocks.py and context.py Dec 27, 2022
@abidlabs abidlabs marked this pull request as ready for review December 27, 2022 15:24
Copy link
Copy Markdown
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome PR @abidlabs !! Will be very helpful as more contributors contribute to gradio as well.

I went through the deployed demos as well and everything looks good from the file refactor. If that's the case after merging in latest main, feel free to merge!

Comment thread gradio/utils.py
Comment thread gradio/components.py
Comment thread scripts/type_check_backend.sh
Comment thread gradio/routes.py Outdated
Comment thread gradio/blocks.py
@abidlabs
Copy link
Copy Markdown
Member Author

abidlabs commented Dec 27, 2022

Thank you for the review @freddyaboulton!

@abidlabs
Copy link
Copy Markdown
Member Author

All the demos look good to me!

@abidlabs abidlabs merged commit de0c41c into main Dec 27, 2022
@abidlabs abidlabs deleted the refactor-pathlib branch December 27, 2022 21:54
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.

2 participants