Title: Decide to deprecate module level functions? · Issue #225 · python-semver/python-semver · GitHub
Open Graph Title: Decide to deprecate module level functions? · Issue #225 · python-semver/python-semver
X Title: Decide to deprecate module level functions? · Issue #225 · python-semver/python-semver
Description: Situation Currently, we have mostly functions which are either on the module level (semver.next_version, semver.bump_*) and almost the same on the VersionInfo level (semver.VersionInfo.next_version, semver.VersionInfo.bump_*). I know, th...
Open Graph Description: Situation Currently, we have mostly functions which are either on the module level (semver.next_version, semver.bump_*) and almost the same on the VersionInfo level (semver.VersionInfo.next_version...
X Description: Situation Currently, we have mostly functions which are either on the module level (semver.next_version, semver.bump_*) and almost the same on the VersionInfo level (semver.VersionInfo.next_version...
Opengraph URL: https://github.com/python-semver/python-semver/issues/225
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Decide to deprecate module level functions?","articleBody":"## Situation\r\n\r\nCurrently, we have mostly functions which are either on the module level (`semver.next_version`, `semver.bump_*`) and almost the same on the `VersionInfo` level (`semver.VersionInfo.next_version`, `semver.VersionInfo.bump_*`).\r\n\r\nI know, they both serve distinctive purposes: the first expects and returns a string whereas the second needs a `VersionInfo` object.\r\n\r\nHowever, from an implementation perspective, I'm wondering if this is double work. It looks inefficient to me when the `VersionInfo` methods need to convert the object first into a string, call the modul level function, and convert it back to a `VersionInfo` object.\r\n\r\nIMHO, we should improve this situation.\r\n\r\n\r\n## Suggested Solution\r\n\r\nThe question boils down to this: should we treat `VersionInfo` as **first class object**?\r\n\r\nI have the impression this isn't currently the case. The developer can decide between two implementation which does mostly the same. The only difference is, one implementation use strings, the other use a \"detour\" with an `VersionInfo` object.\r\n\r\nIf we would treat `VersionInfo` as our one and only solution, that would mean we have to move the implementation into the methods. The module level functions would serve as \"helper functions\".\r\n\r\nOr... maybe we could think about a more radical approach? Are the module level functions really necessary? Should we deprecate them? As we can convert a `VersionInfo` object into a string through `str(versionobject)`, it seems to me, they are obsolete...\r\n\r\nI see the following benefits of this approach:\r\n\r\n* Focus on the `VersionInfo` class, all the magic would happen there. :wink: \r\n* Avoids writing two functions which mostly implements the same functionality, but with different types.\r\n* Simplifies testing.\r\n* Focus more on objects than strings (which can't be controlled).\r\n* Improves the project to be more slim and well-arranged.\r\n* Makes conversion between objects obsolete. Without conversion, it would have a improved effect on performance (maybe only slightly, but...).\r\n\r\nIf we want to follow this path, we would need:\r\n\r\n* Use the `warning` module to issue a deprecation warning in affected module functions.\r\n* Document the change for our upcoming major release. :wink:\r\n* Release 2.9.2 of semver to implement the warnings\r\n* Make the whole removal in release 3 only.\r\n\r\n@gsakkis, @scls19fr Does that make sense to you? Do I miss an important point? I would really like to hear your view on this. :heart: \r\n","author":{"url":"https://github.com/tomschr","@type":"Person","name":"tomschr"},"datePublished":"2020-02-29T17:48:27.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":10},"url":"https://github.com/225/python-semver/issues/225"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:45d59e54-f672-0842-6468-849475e2c83f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 83C2:DD69B:3C0601B:503E931:696F206B |
| html-safe-nonce | f444f4bd541693c303b2528c1e95cde7bcf790a103617ecf6a613c86018a1673 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0MyOkRENjlCOjNDMDYwMUI6NTAzRTkzMTo2OTZGMjA2QiIsInZpc2l0b3JfaWQiOiIxOTE2NTQ5NDk4ODUwNDUxNTY0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dab8809ea7407181e5393f8398d4f5979ed2dbbb0ff0ef7b7e6759c8b9768eca |
| hovercard-subject-tag | issue:573357581 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-semver/python-semver/225/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2f85831c6071e5f5df1c5e13f8c49b04316b1bdd5ba9a0d9ed352ae3b6fa54af/python-semver/python-semver/issues/225 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2f85831c6071e5f5df1c5e13f8c49b04316b1bdd5ba9a0d9ed352ae3b6fa54af/python-semver/python-semver/issues/225 |
| og:image:alt | Situation Currently, we have mostly functions which are either on the module level (semver.next_version, semver.bump_*) and almost the same on the VersionInfo level (semver.VersionInfo.next_version... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tomschr |
| hostname | github.com |
| expected-hostname | github.com |
| None | b278ad162d35332b6de714dfb005de04386c4d92df6475522bef910f491a35ee |
| turbo-cache-control | no-preview |
| go-import | github.com/python-semver/python-semver git https://github.com/python-semver/python-semver.git |
| octolytics-dimension-user_id | 57228994 |
| octolytics-dimension-user_login | python-semver |
| octolytics-dimension-repository_id | 3375726 |
| octolytics-dimension-repository_nwo | python-semver/python-semver |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3375726 |
| octolytics-dimension-repository_network_root_nwo | python-semver/python-semver |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 39aed5006635ab6f45e6b77d23e73b08a00272a3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width