Skip to content

Provide a cleaner way to disable inline comments #268

@gubenkoved

Description

@gubenkoved

As of now in order to suppress "#" interpretation as inline comment we need to use _inspec=True which is really obscure.

This behaviour is documented https://configobj.readthedocs.io/en/latest/configobj.html, however it is still quite clumsy and not clear on the suer code level.

As of ConfigObj 4.3.0 you can also pass in a ConfigObj instance as your configspec. This is especially useful if you need to specify the encoding of your configspec file. When you read your configspec file, you must specify list_values=False. If you need to support hashes inside the configspec values then you must also pass in _inspec=True. This is because configspec files actually use a different syntax to config files and inline comment support must be switched off to correctly read configspec files with hashes in the values.

I suggest to add an explicit way to suppress this behaviour. For example: disable_inline_comments=True.

Reference to standard Python module: https://docs.python.org/3/library/configparser.html.

inline_comment_prefixes, default value: None
Comment prefixes are strings that indicate the start of a valid comment within a config file. comment_prefixes are used only on otherwise empty lines (optionally indented) whereas inline_comment_prefixes can be used after every valid value (e.g. section names, options and empty lines as well). By default inline comments are disabled and '#' and ';' are used as prefixes for whole line comments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions