mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-18 10:44:33 +08:00
added some typing
This commit is contained in:
parent
983535ca50
commit
04e9ea8e52
@ -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):
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user