mypy icon indicating copy to clipboard operation
mypy copied to clipboard

Support type stub generation for `staticmethod`

Open WeilerMarcel opened this issue 2 years ago • 2 comments

Fixes #13574

This PR fixes the generation of type hints for static methods of pybind11 classes. The code changes are based on the suggestions in #13574.

The fix introduces an additional check if the property under inspection is of type staticmethod. If it is, the type information is read from the staticmethod's __func__ attribute, instead of the staticmethod instance itself.

I added a test for C++ classes with static methods bound using pybind11. Both, an overloaded and a non-overloaded static method are tested.

WeilerMarcel avatar Mar 21 '23 18:03 WeilerMarcel

Hi @sobolevn and @AlexWaygood, I updated this PR to work with the latest changes on master. Could you please review the current changes and merge the PR if everything is fine?

WeilerMarcel avatar May 30 '23 05:05 WeilerMarcel

Hey @sobolevn and @AlexWaygood, what is the status of this pull request? I would really like to see it merged into MyPy. Do you need anything from my side to proceed?

WeilerMarcel avatar Jun 28 '23 08:06 WeilerMarcel

Looking forward to this getting merged as well +1

d4n1elchen avatar Jul 12 '23 23:07 d4n1elchen

Hi @sobolevn and @AlexWaygood, please give me an update on this PR. Is there a reason why it has not been merged? As far as I can see, I can not merge it myself since I don't have the necessary permissions.

WeilerMarcel avatar Oct 13 '23 09:10 WeilerMarcel

I can't merge this PR, because I don't fully understand the C++ code, but I think that @JukkaL or @msullivan can help us :)

sobolevn avatar Oct 13 '23 09:10 sobolevn

I can't merge this PR because I'm not a maintainer

AlexWaygood avatar Oct 13 '23 09:10 AlexWaygood

Thanks for the info :) I was under the impression that you could merge, since you were reviewing my changes. I will wait for a reply from @JukkaL and @msullivan.

WeilerMarcel avatar Oct 16 '23 07:10 WeilerMarcel

In the meantime you can resolve conflicts :)

sobolevn avatar Oct 16 '23 07:10 sobolevn

Hi everyone, I integrated my changes into the new master branch and from my perspective it is ready for merging.

I noticed, though, that the mypyc runtime tests with py39-macos seem to be unstable. Since I did not find a way to rerun tests for a commit, I added two empty dummy commits to get the pipeline to succeed. See #16420.

WeilerMarcel avatar Nov 08 '23 10:11 WeilerMarcel

You can ignore the mypyc runtime test failures, since it's a known issue happening on master.

JukkaL avatar Nov 08 '23 13:11 JukkaL

Hi @JukkaL and @msullivan, I resolved conflicts with the current master branch. Can this PR be merged?

WeilerMarcel avatar Dec 05 '23 13:12 WeilerMarcel

Happy new year everyone! 🥳 Are there plans to merge this PR yet? I would really like to get this off my mind.

WeilerMarcel avatar Jan 03 '24 10:01 WeilerMarcel

I can merge this PR if somebody who has more context on the relevant code than I have gives a quick thumbs up.

JukkaL avatar Jan 03 '24 11:01 JukkaL

more context on the relevant code than I have

Or somebody who has any familiarity with the code :-)

JukkaL avatar Jan 03 '24 11:01 JukkaL