Skip to content

Commit

Permalink
Add type annotations for balloons (#4679)
Browse files Browse the repository at this point in the history
* Add type annotations for balloons

* Add cast
  • Loading branch information
harahu committed May 5, 2022
1 parent c8fe042 commit 3badd94
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/streamlit/elements/balloons.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import cast
from typing import cast, TYPE_CHECKING

import streamlit
from streamlit.proto.Balloons_pb2 import Balloons as BalloonsProto

if TYPE_CHECKING:
from streamlit.delta_generator import DeltaGenerator


class BalloonsMixin:
def balloons(self):
def balloons(self) -> "DeltaGenerator":
"""Draw celebratory balloons.
Example
Expand All @@ -31,9 +33,10 @@ def balloons(self):
"""
balloons_proto = BalloonsProto()
balloons_proto.show = True
return self.dg._enqueue("balloons", balloons_proto)
dg = self.dg._enqueue("balloons", balloons_proto)
return cast("DeltaGenerator", dg)

@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)

0 comments on commit 3badd94

Please sign in to comment.