Skip to content

Refactor: registries, wiring, container and exception internals #575

Closed

Description

@lesnik512

This was generated by AI during a pre-4.0 audit of main at 9cd88e7.

Internal, no behaviour change.

  • providers_registry.py:80-82, 112-116, 128-130: generation-checked publish written three times; extract a helper. drop_resolvers duplicates part of _invalidate.
  • (owner, parsed_kwargs, kwargs) data clump (providers_registry.py:64, wiring.py:54): the factory hands its own private fields back with itself; pass the factory.
  • wiring.py:46,48: pure_provider is not static_kwargs; edges aliases provider_kwargs.
  • cache_registry.py:19: CacheItem.settings is None only in tests, so the self.settings and ... guards (:24,50,59,95) are dead in production; the finalize condition is duplicated (:50/:59). cache_registry.py:80: Factory[types.T_co] in a non-generic method, use Factory[typing.Any].
  • factory.py:45-88: __init__ does too much; _validate_kwargs_against_signature calls inspect.signature a second time, carry has_var_keyword on the parsed creator.
  • alias.py:30-43: redirect_target uses an exception for control flow and _compile_alias duplicates find_source; a find_source -> provider | None.
  • Sentinel checks mixed: isinstance(x, UnsetType) vs is UNSET (factory.py:56 vs :83, overrides_registry.py:63).
  • dependency_graph.py:105: DependencyGraph is a stateless class instantiated per call; module functions would do (tests monkeypatch it).
  • Exception __slots__: every DependencyPathMixin user repeats ("_base_message", "dependency_path"); slots save nothing on BaseException. Drop or move onto the mixin.
  • group.py:9,14: typing.Any -> object removes both noqa: ANN401.
  • Naming: SignatureItem.args vs member_types, ParsedCreator.params vs parsed_kwargs; ParsedCreator.return_type is a whole SignatureItem when only .arg_type is used.
  • Comments that break the repo comment rule: container.py:80-82,92,94 (SLF001 rationale twice), container.py:23-25 (_handle_recursion_error docstring narrates the coverage tracer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestready-for-agentFully specified, ready for an AFK agent

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions