added some typing

This commit is contained in:
Abubakar Abid 2022-04-04 09:59:53 -07:00
parent 983535ca50
commit 04e9ea8e52
2 changed files with 13 additions and 6 deletions

View File

@ -189,8 +189,6 @@ class Blocks(Launchable, BlockContext):
return {"type": "column"}
def get_config_file(self):
from gradio.components import Component
config = {"mode": "blocks", "components": [], "theme": self.theme}
for _id, block in self.blocks.items():
config["components"].append(
@ -217,7 +215,7 @@ class Blocks(Launchable, BlockContext):
def __enter__(self):
BlockContext.__enter__(self)
Context.root_block = self
Context.root_block = self # TODO: replace with creating new root block instead of overriding
return self
def __exit__(self, *args):

View File

@ -1,4 +1,13 @@
# Defines the Context class, which is used to store the state of all Blocks that are being rendered.
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING: # Only import for type checking (is False at runtime).
from gradio.blocks import Block
class Context:
root_block = None
block = None
id = 0
root_block: Block = None
block: Block = None # The current block that all children should be added to.
id = 0 # Running unique id for any block that gets defined