Someone was asking me recently why hub/kojihub.py has a convention like:
listChannels = staticmethod(list_channels)
Is it fine to just remove this and use the @staticmethod decorator on all the "public API" methods everywhere?
- Ken
I suspect it is some relict predating python 2.4. But I also wonder, why untagBuild has comment about not being able to be staticmethoded. Mike?
út 30. 6. 2020 v 20:16 odesílatel Ken Dreyer ktdreyer@ktdreyer.com napsal:
Someone was asking me recently why hub/kojihub.py has a convention like:
listChannels = staticmethod(list_channels)
Is it fine to just remove this and use the @staticmethod decorator on all the "public API" methods everywhere?
- Ken
koji-devel mailing list -- koji-devel@lists.fedorahosted.org To unsubscribe send an email to koji-devel-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/koji-devel@lists.fedorahosted.o...
On Wed, Jul 1, 2020 at 7:20 AM Tomas Kopecek tkopecek@redhat.com wrote:
I suspect it is some relict predating python 2.4. But I also wonder, why untagBuild has comment about not being able to be staticmethoded. Mike?
That particular comment is stale. I think originally, this wrapper around _untag_build was very, very simple. So this comment was explaining why it wasn't simply untagBuild = staticmethod(_untag_build). With the current version is there significant code in the wrapper, so of course the latter method would not work.
út 30. 6. 2020 v 20:16 odesílatel Ken Dreyer ktdreyer@ktdreyer.com napsal:
Someone was asking me recently why hub/kojihub.py has a convention like:
listChannels = staticmethod(list_channels)
Is it fine to just remove this and use the @staticmethod decorator on all the "public API" methods everywhere?
- Ken
koji-devel mailing list -- koji-devel@lists.fedorahosted.org To unsubscribe send an email to koji-devel-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/koji-devel@lists.fedorahosted.o...
--
Tomas Kopecek <tkopecek@redhat.com> RHEL Build Development, RedHat
On Tue, Jun 30, 2020 at 2:16 PM Ken Dreyer ktdreyer@ktdreyer.com wrote:
Someone was asking me recently why hub/kojihub.py has a convention like:
listChannels = staticmethod(list_channels)
As Tomas suggests, this code predates python 2.4.
Is it fine to just remove this and use the @staticmethod decorator on all the "public API" methods everywhere?
In this case, and many others, it is not that simple. ListChannels is defined inside the RootExports class, but list_channels is a module level function. You can't just add the decorator to it.
This is just a more compact and efficient way of adding an internal function to the exports when we don't need to add any wrapper code.
- Ken
koji-devel mailing list -- koji-devel@lists.fedorahosted.org To unsubscribe send an email to koji-devel-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/koji-devel@lists.fedorahosted.o...
Thanks for the explanation! That helps me understand the reasoning behind the way hojihub.py is organized.
I wonder if we could move all the methods out of the RootExports class and into a separate Python module, and then pass that module into register_module(). That would simplify the code and remove the "staticmethod()" bits.
- Ken
On Wed, Jul 1, 2020 at 7:00 AM Michael McLean mikem@redhat.com wrote:
On Tue, Jun 30, 2020 at 2:16 PM Ken Dreyer ktdreyer@ktdreyer.com wrote:
Someone was asking me recently why hub/kojihub.py has a convention like:
listChannels = staticmethod(list_channels)
As Tomas suggests, this code predates python 2.4.
Is it fine to just remove this and use the @staticmethod decorator on all the "public API" methods everywhere?
In this case, and many others, it is not that simple. ListChannels is defined inside the RootExports class, but list_channels is a module level function. You can't just add the decorator to it.
This is just a more compact and efficient way of adding an internal function to the exports when we don't need to add any wrapper code.
- Ken
koji-devel mailing list -- koji-devel@lists.fedorahosted.org To unsubscribe send an email to koji-devel-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/koji-devel@lists.fedorahosted.o...
koji-devel mailing list -- koji-devel@lists.fedorahosted.org To unsubscribe send an email to koji-devel-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/koji-devel@lists.fedorahosted.o...
koji-devel@lists.stg.fedorahosted.org