Last active
August 28, 2024 01:17
-
-
Save dimaqq/d00d6c2d72762ad3b4a3df986f849690 to your computer and use it in GitHub Desktop.
Fixing ops.main() type hints, the protocol version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Protocol, cast | |
import ._main | |
import .main as _legacy_main | |
class Main(Protocol): | |
def __call__(self, arg1: Arg1, ...): ... | |
def main(self, arg1: Arg1, ...): ... | |
main = cast(Main, _main.main) | |
main.main = _legacy_main.main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Move code from today's ops/main.py here | |
def _emit_charm_event(...): | |
code code | |
def main(arg1: Arg1, ...): | |
code code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Warning: this module is deprecated, kept only for backwards compatibility | |
# todo: warnings.deprecated is py 3.13 feature, we'd vendor a simplified copy | |
from warnings import deprecated | |
import ._main | |
main = deprecated("Call opa.main() instead")(_main.main) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment