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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider adapting a typestate-ish pattern for context manager-based components #740

Open
janbuchar opened this issue Nov 25, 2024 · 0 comments
Labels
solutioning The issue is not being implemented but only analyzed and planned. t-tooling Issues with this label are in the ownership of the tooling team.

Comments

@janbuchar
Copy link
Collaborator

janbuchar commented Nov 25, 2024

It would probably be hard to do so without straying even further from how the JS implementation works, but it may be easier to just do something like

class EventManager:
  async def __aenter__(self) -> EventManagerContext:
    pass
  # ... no methods that need to be called on an initialized event manager

class EventManagerContext:
  def emit():
    pass
  # and whatever else needs an initialized context manager

... and so on for everything with an initialization step. Honestly, even BasicCrawler could benefit from this - the tracking of active state is kinda hairy there as well.

Originally posted by @janbuchar in #714 (comment)

@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 25, 2024
@janbuchar janbuchar added the solutioning The issue is not being implemented but only analyzed and planned. label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solutioning The issue is not being implemented but only analyzed and planned. t-tooling Issues with this label are in the ownership of the tooling team.
Projects
None yet
Development

No branches or pull requests

1 participant