Skip to content

Commit

Permalink
Typing framework.py (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti authored Jun 23, 2022
1 parent ad82d37 commit 92e8b36
Show file tree
Hide file tree
Showing 4 changed files with 278 additions and 196 deletions.
4 changes: 2 additions & 2 deletions ops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@
"""

# Import here the bare minimum to break the circular import between modules
from . import charm # noqa: F401 (imported but unused)
from .version import version as __version__ # noqa: F401 (imported but unused)
from . import charm # type: ignore # noqa
from .version import version as __version__ # type: ignore # noqa
7 changes: 6 additions & 1 deletion ops/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import pathlib
import typing
from typing import TYPE_CHECKING

from ops import model
from ops._private import yaml
Expand Down Expand Up @@ -669,8 +670,12 @@ def __init__(self, *args):

# note that without the #: below, sphinx will copy the whole of CharmEvents
# docstring inline which is less than ideal.
#: Used to set up event handlers; see :class:`CharmEvents`.
# Used to set up event handlers; see :class:`CharmEvents`.
on = CharmEvents()
if TYPE_CHECKING:
# to help the type checker and IDEs:
@property
def on(self) -> CharmEvents: ... # noqa

def __init__(self, framework: Framework, key: typing.Optional = None):
super().__init__(framework, None)
Expand Down
Loading

0 comments on commit 92e8b36

Please # to comment.