Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add current working directory as first config path #291

Merged
merged 1 commit into from Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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