Repository navigation
Implement a help() method for the configuration system - #13499
Conversation
|
I haven't looked at the code in detail but this is an awesome idea. 💯 |
|
I like the idea too, but wonder if a simpler solution to the problem is not to define a |
|
Actually, just because I (EDIT: thought wouldn't it be nice if one could just do "help(something)" and) wondered what would happen, |
Python's builtin
astropy/astropy/config/configuration.py Lines 394 to 404 in f2c67ef However, thanks to I have updated the pull request so that if help is printed for multiple configuration items then the entries are separated with empty lines, and there is now an example in the docstring. |
|
I guess we should separate the two concerns, but right now, while the configitems may have a nice Note that in All that said, I definitely see your point that just from tab-completion, it is nearly impossible to get useful information; e.g., |
a437d54 to
cc417bc
Compare
|
I've implemented I have converted this pull request to a draft so that we could discuss if the |
|
@mhvk, does the proposed implementation address your remarks? |
This comment was marked as outdated.
This comment was marked as outdated.
|
@mhvk, could you have a look at this? I converted this pull request to a draft in case we want to also change |
|
I'm so sorry that this keeps slipping by. The problem is mostly that really all I remember is a feeling of disquiet at this, but I know that I actually have to look at things again, for which I don't really have time right now. It may be more logical is some of the people who wrote the configuration system had a look, so let's ping @eteq, @saimn and @WilliamJamieson . |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
39eea30 to
3603b8d
Compare
|
The pull request now matches my branch, so this is ready for review. A short summary of this pull request is that it implements |
|
I have updated the example outputs of the code, both in the tests and in the documentation. As they are written now they are closer to the actual outputs users would see. The cost of doing this are a few overlong lines, but I think not having artificial line breaks in the examples is a good enough excuse. |
This comment was marked as outdated.
This comment was marked as outdated.
|
I rebased this once more as requested by https://groups.google.com/g/astropy-dev/c/9DO4YkoU44g |
The new string representation of a `ConfigNamespace` contains the string representations of the configuration items stored within it, so passing a `ConfigNamespace` to Python's built-in `print()` results in an informative message.
|
codecov upload failed, so we can ignore the coverage complain. |
|
Despite using a |
|
I think this also works for downstream packages that uses the config system (e.g., |
The new `ConfigNamespace.help()` method prints the string representation of the specified `ConfigItem`, or of the `ConfigNamespace` itself.
pllim
left a comment
There was a problem hiding this comment.
Sorry this dragged on so long. Thanks!
ConfigIteminstances have adescriptionattribute, the contents of which are written to the configuration file as comments. However, there is currently no convenient way of accessing thedescriptionstrings through the configuration system at runtime (see the awkward code examples in the documentation that this pull request replaces). The newConfigNamespace.help()method provides a user-friendly way of seeing the name, current value, type and description of one or more configuration items.Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CIlabel.no-changelog-entry-neededlabel. If this is a manual backport, use theskip-changelog-checkslabel unless special changelog handling is necessary.astropy-botcheck might be missing; do not let the green checkmark fool you.backport-X.Y.xlabel(s) before merge.