Defer preferred_dir validation until root_dir is set #826
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When one trait depends on another for its validity, both traits should be loaded prior to the validation of the dependent trait. Such a relationship occurs between
preferred_dir
androot_dir
, wherepreferred_dir
must reside within the hierarchy ofroot_dir
. However, whenpreferred_dir
is defined via a CLI parameter (e.g.,--ServerApp.preferred_dir = /foo
), its validation will occur prior to the finalization ofroot_dir
ifroot_dir
is defined in a configuration file (since CLI traits are validated prior to those loaded from config files). In such cases, we need to defer the validation ofpreferred_dir
(relative to the value ofroot_dir
) untilroot_dir
is validated. This pull request detects whenpreferred_dir
is set via the CLI and, in such cases, defers its validation untilroot_dir
is validated OR the application's superclass is initialized. This latter scenario will occur if the default value ofroot_dir
is used (i.e., current working directory).In the course of testing, it turns out that there's no way to test various configuration locations of
root_dir
since the pytest fixtures pass this trait directly (so even the default value can't be used). This pull request introduces the ability to configureroot_dir
by detecting it has aNone
value and, in such cases, removes it from the keyword arguments.Resolves: #806