python-injector / python-injector/injector

[Discussion] Entering/Existing Scopes?

Open
#162 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.5k
Forks
94
PR merge metrics
No merged PRs in 30d

Description

Hi, let me start from thanking for the awesome project 🎉

Recently I was implementing a custom scope and I noticed a need for explicitly demarking beginning and ending of this scope. Mine was similar to flask_injector's RequestScope but could also be used outside web framework context, i.e. in background jobs or CLI commands.

I know injector is heavily inspired by Guice and I noticed in their documentation that their API supports enter and exit methods.

I'd like to start a brainstorming about this concept to either:

  • introduce a new API for entering/exiting a scope - similar to configure, provide empty enter, exit methods to be overriden,
  • expand documentation to give others tips to implement such a thing on their own,
  • other?

BTW, here's my custom scope implementation: https://github.com/Enforcer/clean-architecture/blob/master/auctioning_platform/main/main/modules.py#L21 Basically, it's a copy-pasted ThreadLocalScope with extras.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the discussion and the linked custom scope implementation in auctioning_platform/main/main/modules.py, then compare its needs with Guice's custom-scope documentation. Done means reaching a decision on whether to add enter/exit support, expand the documentation, or pursue another direction; no specific tests or files are identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.