Skip to content

Workaround solution for issue #26818 #26826

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

Merged
merged 1 commit into from
Jan 28, 2025
Merged

Workaround solution for issue #26818 #26826

merged 1 commit into from
Jan 28, 2025

Conversation

devatbosch
Copy link

@devatbosch devatbosch commented Jan 23, 2025

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@devatbosch
Copy link
Author

Hi @asmorkalov ,

The pipeline page says, "Service is in degraded state" . Any idea on when it will be up and running...

@Kumataro
Copy link
Contributor

Oh, sorry I have mistake. this pull request is not enoght to fix original issue. we have to test with "mypy".

@devatbosch
Copy link
Author

Hi @Kumataro , I made the suggested and required changes by pushing the commit df6e3c1 to fix this issue After testing it with success in my local system.

@devatbosch devatbosch requested a review from VadimLevin January 24, 2025 12:56
Copy link
Contributor

@VadimLevin VadimLevin left a comment

Choose a reason for hiding this comment

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

Squash commits and keep changes only in predefined_types.py

@Kumataro
Copy link
Contributor

Kumataro commented Jan 25, 2025

Thank you for your continuous helping.
I think ‘git revert command` is helpful to revert commit.
After that, this pull request will be squashed into only 1 change.

git revert 6038669
git revert df6e3c1
git revert 5e5857a

And If possible, could you fix code indent like Mat ? (I think you can fix to override without reverting commit)
After reformating, you can remove draft mark.

AliasTypeNode.union_(
"Mat",
items=(ASTNodeTypeNode("Mat", module_name="cv2.mat_wrapper"),
AliasRefTypeNode("NumPyArrayNumeric")),
export_name="MatLike"
),

kmtr@kmtr-VMware-Virtual-Platform:~/work/opencv4$ git diff -b 4a4031dc48475ec3354d28a3cdedda57a8913443
diff --git a/modules/python/src2/typing_stubs_generation/predefined_types.py b/modules/python/src2/typing_stubs_generation/predefined_types.py
index c5f49b5122..d32fd9b934 100644
--- a/modules/python/src2/typing_stubs_generation/predefined_types.py
+++ b/modules/python/src2/typing_stubs_generation/predefined_types.py
@@ -54,8 +54,12 @@ _PREDEFINED_TYPES = (
                             doc="Required length is 2"),
     AliasTypeNode.sequence_("Size2f", PrimitiveTypeNode.float_(),
                             doc="Required length is 2"),
-    AliasTypeNode.sequence_("Scalar", PrimitiveTypeNode.float_(),
-                            doc="Required length is at most 4"),
+    AliasTypeNode.union_(
+    "Scalar",
+    items=(SequenceTypeNode("Scalar", PrimitiveTypeNode.float_()),
+           PrimitiveTypeNode.float_()),
+    doc="Max sequence length is at most 4"
+    ),
     AliasTypeNode.sequence_("Point", PrimitiveTypeNode.int_(),
                             doc="Required length is 2"),
     AliasTypeNode.ref_("Point2i", "Point"),
kmtr@kmtr-VMware-Virtual-Platform:~/work/opencv4$

Updated predefined_types.py to keep changes only as suggested in 

opencv#26826 (review)

opencv#26826 (comment)
@devatbosch devatbosch reopened this Jan 27, 2025
@devatbosch
Copy link
Author

devatbosch commented Jan 27, 2025

Hi @VadimLevin ,

As you suggested, I stashed all other changes except for the one suggested here #26826 (comment) for predefined_datatypes.py

Also, @Kumataro , as you indicated I kept the indent same as per the one you suggested here #26826 (comment)

Thanks for all your help.

@VadimLevin could you please have a look and let me know if anything else is needed to be done...

@VadimLevin As I newly started to the world of open-source hence I have been pretty much afraid of making any changes that might cause the sys to break, but I believe if the community supports me I would also be able to debug, test and write code in a much more professional manner.

Thank You!

@devatbosch devatbosch requested a review from VadimLevin January 27, 2025 05:33
@devatbosch devatbosch marked this pull request as ready for review January 27, 2025 05:34
Copy link
Contributor

@VadimLevin VadimLevin left a comment

Choose a reason for hiding this comment

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

Generated typing/__init__.py entry:

Scalar = _typing.Union[_typing.Sequence[float], float]
"""Max sequence length is at most 4"""

@asmorkalov asmorkalov merged commit 0049cde into opencv:4.x Jan 28, 2025
27 of 55 checks passed
@asmorkalov asmorkalov added this to the 4.12.0 milestone Jan 28, 2025
@asmorkalov asmorkalov changed the title Workaround solution for isuue #26818 Workaround solution for issue #26818 Jan 28, 2025
@devatbosch
Copy link
Author

devatbosch commented Jan 28, 2025

@VadimLevin , thanks for reviewing and merging the PR.

@asmorkalov asmorkalov mentioned this pull request Feb 19, 2025
NanQin555 pushed a commit to NanQin555/opencv that referenced this pull request Feb 24, 2025
Updated predefined_types.py to keep changes only as suggested in 

opencv#26826 (review)

opencv#26826 (comment)
killerdevildog added a commit to killerdevildog/opencv that referenced this pull request Aug 12, 2025
Addresses issues opencv#27528, opencv#26818, opencv#26826 by implementing the function
overloads solution suggested by VadimLevin in PR opencv#27620.

Changes:
1. predefined_types.py: Change Scalar from Union to Sequence[float]
2. api_refinement.py: Add global function overload generation
3. Generate both Scalar and float overloads for drawing functions

This provides better MyPy compatibility while maintaining backward
compatibility. All existing code continues to work unchanged.

Testing: Comprehensive test suite validates all scenarios pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants