Skip to content

Commit

Permalink
Merge pull request #291 from blink1073/fix-paths-output
Browse files Browse the repository at this point in the history
Add current working directory as first config path
  • Loading branch information
jasongrout committed Sep 26, 2022
2 parents 1cedf84 + ca98ef6 commit 810ceb7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions jupyter_core/application.py
Expand Up @@ -88,8 +88,8 @@ def _config_dir_default(self):
def config_file_paths(self):
path = jupyter_config_path()
if self.config_dir not in path:
path.insert(0, self.config_dir)
path.insert(0, os.getcwd())
# Insert config dir after cwd.
path.insert(1, self.config_dir)
return path

data_dir = Unicode()
Expand Down
2 changes: 1 addition & 1 deletion jupyter_core/paths.py
Expand Up @@ -251,7 +251,7 @@ def jupyter_config_path():
# jupyter_config_dir makes a blank config when JUPYTER_NO_CONFIG is set.
return [jupyter_config_dir()]

paths: list = []
paths: list = [os.getcwd()]

# highest priority is explicit environment variable
if os.environ.get("JUPYTER_CONFIG_PATH"):
Expand Down
9 changes: 6 additions & 3 deletions jupyter_core/tests/test_paths.py
Expand Up @@ -287,6 +287,7 @@ def test_jupyter_config_path():
values = list(
dict.fromkeys(
[
os.getcwd(),
jupyter_config_dir(),
os.path.join(site.getuserbase(), "etc", "jupyter"),
paths.ENV_CONFIG_PATH[0],
Expand All @@ -300,8 +301,9 @@ def test_jupyter_config_path():
def test_jupyter_config_path_no_user_site():
with patch.object(site, "ENABLE_USER_SITE", False):
path = jupyter_config_path()
assert path[0] == jupyter_config_dir()
assert path[1] == paths.ENV_CONFIG_PATH[0]
assert path[0] == os.getcwd()
assert path[1] == jupyter_config_dir()
assert path[2] == paths.ENV_CONFIG_PATH[0]


def test_jupyter_config_path_prefer_env():
Expand All @@ -312,6 +314,7 @@ def test_jupyter_config_path_prefer_env():
values = list(
dict.fromkeys(
[
os.getcwd(),
paths.ENV_CONFIG_PATH[0],
jupyter_config_dir(),
os.path.join(site.getuserbase(), "etc", "jupyter"),
Expand All @@ -332,7 +335,7 @@ def test_jupyter_config_path_env():

with patch.dict("os.environ", {"JUPYTER_CONFIG_PATH": path_env}):
path = jupyter_config_path()
assert path[:2] == [pjoin("foo", "bar"), pjoin("bar", "baz")]
assert path[1:3] == [pjoin("foo", "bar"), pjoin("bar", "baz")]


def test_prefer_environment_over_user():
Expand Down

0 comments on commit 810ceb7

Please sign in to comment.