Repository navigation
Commit c4cea87
committed
Config: Remove use of
The `Option.default` property would return the global constant
`NO_DEFAULT` in case the option does not specify a default. The idea was
that it could be used to distinguish between an option not defining a
default and one defining the default to be `None`.
The problem is that in the various methods that return a config option
value, such as `Config.get_option` could also return this value. This
would be problematic for certain CLI command options that used the
`aiida.manage.configuration.get_config_option` function to set the
default. If the config option was not defined, the function would return
`()` which is the value of the `NO_DEFAULT` constant. When the option
accepts string values, this value would often even silently be accepted
although it almost certainly is not what the user intended.
This would actually happen for the tests of `verdi setup`, which has the
options `--email`, `--first-name`, `--last-name` and `--institution`
that all define a default through `get_config_option` and therefore the
default would be actually set to `()` in case the config did not specify
these global config options.
Since for config options there is no current use-case for actually
setting a default to `None`, there is no need to distinguish between
this case and a default never having been defined, and so the `NO_DEFAULT`
global constant is removed and replaced by `None`.NO_DEFAULT for Option.default
1 parent 7e1ea7b commit c4cea87
3 files changed
Lines changed: 5 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
81 | 80 | | |
82 | 81 | | |
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | 85 | | |
87 | 86 | | |
88 | | - | |
| 87 | + | |
89 | 88 | | |
90 | 89 | | |
91 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| |||
442 | 442 | | |
443 | 443 | | |
444 | 444 | | |
445 | | - | |
446 | | - | |
447 | | - | |
| 445 | + | |
448 | 446 | | |
449 | 447 | | |
450 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | | - | |
19 | 17 | | |
20 | 18 | | |
21 | 19 | | |
| |||
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | | - | |
| 42 | + | |
45 | 43 | | |
46 | 44 | | |
47 | 45 | | |
| |||
0 commit comments