Skip to content

Comments

feat: add static evaluation of activators#646

Closed
fadedDexofan wants to merge 5 commits intoreagento:developfrom
fadedDexofan:feature/static-activator-evaluation
Closed

feat: add static evaluation of activators#646
fadedDexofan wants to merge 5 commits intoreagento:developfrom
fadedDexofan:feature/static-activator-evaluation

Conversation

@fadedDexofan
Copy link
Contributor

@fadedDexofan fadedDexofan commented Jan 25, 2026

Classify activators as STATIC/DYNAMIC and evaluate static ones at container creation time, stripping inactive providers from the dependency graph.

Closes #642

@github-actions
Copy link

github-actions bot commented Jan 25, 2026

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/dishka
  activator_classifier.py
  async_container.py
  container.py
  factory_index.py
  processed_factory_filter.py 72, 83-84
  registry_builder.py 632, 639, 647, 669
  static_evaluator.py 41, 45, 48, 62, 66-69, 112, 121-122, 146
  src/dishka/dependency_source
  activator.py
Project Total  

This report was generated by python-coverage-comment-action

Classify activators as STATIC/DYNAMIC and evaluate static ones
at container creation time, stripping inactive providers from
the dependency graph.
@fadedDexofan fadedDexofan force-pushed the feature/static-activator-evaluation branch from 37d9436 to 430f305 Compare January 25, 2026 12:36
Initial implementation evaluated activators after `build()`, leaving dead branches in SELECTORs. Move evaluation into `RegistryBuilder.build()` before `_unite_selectors()` to filter inactive factories earlier.
@fadedDexofan fadedDexofan marked this pull request as ready for review January 25, 2026 15:44
@fadedDexofan fadedDexofan marked this pull request as draft January 25, 2026 15:44
@fadedDexofan fadedDexofan marked this pull request as ready for review January 25, 2026 16:10
case None:
return True
case BoolMarker():
return None if not marker.value else True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return marker.value?

- Fix duplicate condition bug in activator.py (Marker → BaseMarker)
- Add type guard before isinstance() in static_evaluator.py
- Extract _get_factory_deps() to reduce duplication in classifier
- Add caching for inheritance-based context lookups
- Extract HasMarkerEvaluator class for better SRP
- Add 17 unit tests for ActivatorClassifier
@sonarqubecloud
Copy link

from dishka.factory_index import FactoryIndex


class HasMarkerEvaluator:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of markers should handled differently. All markers must be proceded in the same way.


source = factory.source
if factory.is_to_bind and args:
result = source(args[0], *args[1:], **kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binding is done in factory, do not reimplement it

from dishka.factory_index import FactoryIndex


def _make_factory(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to create factories manually, use provide

@Tishka17
Copy link
Member

AI generated code. A lot of decisions are discussable. Closing as author is not able to discuss it

@Tishka17 Tishka17 closed this Jan 25, 2026
@github-project-automation github-project-automation bot moved this to To be released in Dishka kanban Jan 25, 2026
fadedDexofan added a commit to fadedDexofan/dishka that referenced this pull request Jan 25, 2026
- BoolMarker now returns marker.value directly
- Remove is_to_bind reimplementation (factory handles binding)
- Remove test_activator_classifier.py (internal class, behavior
  covered by integration tests in test_static_evaluation.py)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be released

Development

Successfully merging this pull request may close these issues.

Static evaluation of activators

2 participants