Skip to content

Fix for annotated injection with attribute. Replacing with origins on… #266

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

sergey-zinchenko
Copy link

There is a problem injecting annotated type. I created a test for that to demonstrate. Shortly: we should not replace annotated type with its origin while building bindings if the annotation is not a injection marker (ie inject or noinject)

…ly injections markers but not general annotations.
@sergey-zinchenko
Copy link
Author

sergey-zinchenko commented Feb 23, 2025

for the issue 267 @jstasiak can you pls check?

@sergey-zinchenko
Copy link
Author

@jstasiak pls review

Copy link
Collaborator

@davidparsson davidparsson left a comment

Choose a reason for hiding this comment

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

I think this is a useful addition, but I also think that we need to consider this a breaking change. The previous implementation has its drawbacks, but if anyone relies on that, this change will break things for them. This PR will also have conflicts with #269, where the markers have been renamed to be made public.

@sergey-zinchenko
Copy link
Author

@davidparsson I added a slight change to the decorators' behavior. I enabled the usage of annotated types in hints of provider and multi-provider.

@filipnestak
Copy link

filipnestak commented Mar 13, 2025

@sergey-zinchenko @davidparsson I have similar PR for this fix. Tests fails because github runners not executed.
#263

@davidparsson
Copy link
Collaborator

@sergey-zinchenko, your changes are not following the black format conventions. Please update that.

@sergey-zinchenko
Copy link
Author

@davidparsson formatting applied

@sergey-zinchenko
Copy link
Author

@davidparsson pls re-run the pipeline. I checked on my fork, and the pipeline succeeded.

@sergey-zinchenko
Copy link
Author

sergey-zinchenko commented Mar 14, 2025

@davidparsson, regarding your comment, I want to clarify that, in my opinion, this pull request is primarily a fix rather than a breaking change. The injection of annotated types partially malfunctioned, resulting in the source type being used to construct objects instead of the annotated type. It may be treated as a bug because, consequently, it was not possible to use two annotated types derived from the same source (for example, Annotated[str, "foo"] and Annotated[str, "bar"]) due to the issue that caused the last registered binding to be injected as a string rather than an annotated type.

This pull request significantly enhances the usability of annotated types within the library. This fix is crucial for several of my projects, as the use of numerous annotated types is currently infeasible without it. Therefore, applying this fix is essential to ensure the proper injection of annotated types.

@davidparsson
Copy link
Collaborator

Yes, I agree and fully understand. I don't think that there are alot of users that rely on the current/old behavor, but I can only guess, and for those users this is a breaking change, even if the old behavor was not intentional.

That said, I don't see that as a reason to reject this, but rather as an input to the versioning of the next release.

One could also argue that that since the previous behavior was unintentional and rather useless, it is safe to assume that nobody relies on that, and thus not consider this a breaking change. But in a strict sense, the behavior would change in a way that is not backwards-compatible.

@sergey-zinchenko
Copy link
Author

Yup. It may make sense to indicate that change may break the code based on the old behavior.

@sergey-zinchenko
Copy link
Author

@davidparsson what are the next steps to merge that PR?

@davidparsson
Copy link
Collaborator

I would like @jstasiak's review and thoughts on how to classify this change. I think it's a reasonable change, but I don't want to make this decision myself.

@sergey-zinchenko
Copy link
Author

@davidparsson @jstasiak is there any decision on that?

@sergey-zinchenko
Copy link
Author

sergey-zinchenko commented Apr 4, 2025

@jstasiak @davidparsson ping. I need that change)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants