Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argument types for iframe #4707

Merged
merged 1 commit into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 15 additions & 14 deletions lib/streamlit/elements/iframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional
from typing import cast
from typing import cast, Optional, TYPE_CHECKING

import streamlit
from streamlit.proto.IFrame_pb2 import IFrame as IFrameProto

if TYPE_CHECKING:
from streamlit.delta_generator import DeltaGenerator


class IframeMixin:
def _iframe(
self,
src,
width=None,
height=None,
scrolling=False,
src: str,
width: Optional[int] = None,
height: Optional[int] = None,
scrolling: bool = False,
):
"""Load a remote URL in an iframe.

Expand Down Expand Up @@ -55,10 +56,10 @@ def _iframe(

def _html(
self,
html,
width=None,
height=None,
scrolling=False,
html: str,
width: Optional[int] = None,
height: Optional[int] = None,
scrolling: bool = False,
):
"""Display an HTML string in an iframe.

Expand Down Expand Up @@ -87,13 +88,13 @@ def _html(
return self.dg._enqueue("iframe", iframe_proto)

@property
def dg(self) -> "streamlit.delta_generator.DeltaGenerator":
def dg(self) -> "DeltaGenerator":
"""Get our DeltaGenerator."""
return cast("streamlit.delta_generator.DeltaGenerator", self)
return cast("DeltaGenerator", self)


def marshall(
proto,
proto: IFrameProto,
src: Optional[str] = None,
srcdoc: Optional[str] = None,
width: Optional[int] = None,
Expand Down