Skip to content

Preferences can't be unset if they are the only one on a given node. #312

Description

@nicolasap-dm

From the IPreference documentation, it's unclear to me whether I should use preferences.clear(key) or preferences.remove(key) to un-set a preference.

However, it looks as though neither works.

Is it possible to remove a preference altogether? And if so, should one of these two methods work to that end?

Expected

For preferences that are stored to file, if there is a preference at some key (namespace.key), it should be possible to remove that preference altogether.

Consider this initial situation:

>>> def cat(fname):
...     with open(fname, "r") as f:
...         print(f.read())
... 
>>> preferences = Preferences(filename="example.ini")
>>> preferences.set("namespace.field", "value")
>>> preferences.flush()
>>> cat("example.ini")
[namespace]
field = value

I would expect that

preferences.remove("namespace.field")
preferences.flush()

would result in a empty example.ini file.

Observed

Neither approach works:

>>> preferences.remove("namespace.field")
>>> preferences.flush()
>>> cat("example.ini")
[namespace]
field = value

>>> preferences.clear("namespace.field")
>>> preferences.flush()
>>> cat("example.ini")
[namespace]
field = value

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions