Title: Are non-reified docstrings acceptable? · gitpython-developers/GitPython · Discussion #1734 · GitHub
Open Graph Title: Are non-reified docstrings acceptable? · gitpython-developers/GitPython · Discussion #1734
X Title: Are non-reified docstrings acceptable? · gitpython-developers/GitPython · Discussion #1734
Description: Are non-reified docstrings acceptable?
Open Graph Description: Unlike modules, classes, and functions/methods, variables/constants do not technically support docstrings. However, it is fairly common to write what is conceptually a docstring immediately after a...
X Description: Unlike modules, classes, and functions/methods, variables/constants do not technically support docstrings. However, it is fairly common to write what is conceptually a docstring immediately after a...
Opengraph URL: https://github.com/gitpython-developers/GitPython/discussions/1734
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Are non-reified docstrings acceptable?","text":"Unlike modules, classes, and functions/methods, variables/constants do not technically support docstrings. However, it is fairly common to write what is conceptually a docstring immediately after an assignment statement, as an expression statement consisting of a triple-quoted string, with no blank line in between. This is recognized by some editors, including VS Code, as a docstring, and helpfully displayed when one hovers over or otherwise examines information on the variable/constant it documents. Of course, calling help on the variable/constant does not reveal it; while true docstrings become __doc__ attributes, this informal kind of docstring cannot and does not affect an object's __doc__ attribute at runtime. (It is reflected in the AST, because it is a statement, but it is non-reified in the sense that, unlike true docstrings, it has no place in the data model.)
\nI think it would be useful to convert some comments atop variable/constant assignment statements to this kind of \"docstring\", and perhaps to add them for some variables/constants that currently are not directly documented. But I wanted to check, since it may be that for this project only true docstrings are preferred.
\nAs an example of this, here's one change that could be made in test_util.py:
\n-# Mapping of expected failures for the test_cygpath_ok test.\n _cygpath_ok_xfails = {\n # From _norm_cygpath_pairs:\n (R\"C:\\Users\", \"/cygdrive/c/Users\"): \"/proc/cygdrive/c/Users\",\n (R\"C:\\d/e\", \"/cygdrive/c/d/e\"): \"/proc/cygdrive/c/d/e\",\n (\"C:\\\\\", \"/cygdrive/c/\"): \"/proc/cygdrive/c/\",\n (R\"\\\\server\\BAR/\", \"//server/BAR/\"): \"//server/BAR\",\n (R\"D:/Apps\", \"/cygdrive/d/Apps\"): \"/proc/cygdrive/d/Apps\",\n (R\"D:/Apps\\fOO\", \"/cygdrive/d/Apps/fOO\"): \"/proc/cygdrive/d/Apps/fOO\",\n (R\"D:\\Apps/123\", \"/cygdrive/d/Apps/123\"): \"/proc/cygdrive/d/Apps/123\",\n # From _unc_cygpath_pairs:\n (R\"\\\\?\\a:\\com\", \"/cygdrive/a/com\"): \"/proc/cygdrive/a/com\",\n (R\"\\\\?\\a:/com\", \"/cygdrive/a/com\"): \"/proc/cygdrive/a/com\",\n }\n+\"\"\"Mapping of expected failures for the test_cygpath_ok test.\"\"\"
\n(Ordinarily I might just open a PR, which could be merged or not. But exactly where I'd add these depends on decisions related to other PRs: at least #1732, and possibly also a forthcoming PR that builds on #1729. So I figured I'd post this question instead.)
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Thanks for bringing this up!
\nI think GitPython should try to provide a decent in-editor experience, and this seems to be improved by turning these comments on constants into non-reified docstrings. This would also be a guiding principle - there are no rules except for \"don't break anyone\" and \"don't make it worse more than you make it better\" :).
","upvoteCount":2,"url":"https://github.com/gitpython-developers/GitPython/discussions/1734#discussioncomment-7484116"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:4be0bc2f-8a51-fdb7-ae5c-aacea74a5a5a |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | 9BF2:25046C:1869CB:229AA0:6968B76A |
| html-safe-nonce | dc339c600e06a9b19140a47ea189ea96459c13669f5d4f0372c0537d50a1e579 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5QkYyOjI1MDQ2QzoxODY5Q0I6MjI5QUEwOjY5NjhCNzZBIiwidmlzaXRvcl9pZCI6IjE0NzQyODk0MzY0MTEzNDQ3NDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | fea5c7a9c371042f719c6d087a7df887b23501d209b04188865c57f60a151842 |
| hovercard-subject-tag | discussion:5812445 |
| github-keyboard-shortcuts | repository,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/Voltron::DiscussionsFragmentsController/show/gitpython-developers/GitPython/1734/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/721bb20bd628efd5539c0574ce3bc862e863141b5f80d22503923f3ac170d8a2/gitpython-developers/GitPython/discussions/1734 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/721bb20bd628efd5539c0574ce3bc862e863141b5f80d22503923f3ac170d8a2/gitpython-developers/GitPython/discussions/1734 |
| og:image:alt | Unlike modules, classes, and functions/methods, variables/constants do not technically support docstrings. However, it is fairly common to write what is conceptually a docstring immediately after a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdc7c66bd36a6c12eb8e771e806db863266e573fc299e77f27505a768d4f8a98 |
| turbo-cache-control | no-preview |
| go-import | github.com/gitpython-developers/GitPython git https://github.com/gitpython-developers/GitPython.git |
| octolytics-dimension-user_id | 503709 |
| octolytics-dimension-user_login | gitpython-developers |
| octolytics-dimension-repository_id | 1126087 |
| octolytics-dimension-repository_nwo | gitpython-developers/GitPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1126087 |
| octolytics-dimension-repository_network_root_nwo | gitpython-developers/GitPython |
| 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 | 3223a6503d318917691422cdadfbe16cd8fb21e5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width