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

Use xdg #11108

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Use xdg #11108

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241207-155958.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Use xdg and also fix circular dep
time: 2024-12-07T15:59:58.137140008-08:00
custom:
Author: dradetsky
Issue: "2515"
1 change: 0 additions & 1 deletion core/dbt/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .main import cli as dbt_cli # noqa
7 changes: 6 additions & 1 deletion core/dbt/cli/resolvers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path

from appdirs import user_config_dir

from dbt.config.project import PartialProject
from dbt.exceptions import DbtProjectError

Expand All @@ -11,7 +13,10 @@ def default_project_dir() -> Path:


def default_profiles_dir() -> Path:
return Path.cwd() if (Path.cwd() / "profiles.yml").exists() else Path.home() / ".dbt"
if (Path.cwd() / "profiles.yml").exists():
return Path.cwd()
else:
return Path(user_config_dir(appname="dbt", appauthor="dbt-labs"))


def default_log_path(project_dir: Path, verify_version: bool = False) -> Path:
Expand Down
10 changes: 1 addition & 9 deletions core/dbt/config/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Any, Dict, Optional, Tuple

from dbt.adapters.contracts.connection import Credentials, HasCredentials
from dbt.cli.resolvers import default_profiles_dir
from dbt.clients.yaml_helper import load_yaml_text
from dbt.contracts.project import ProfileConfig
from dbt.events.types import MissingProfileTarget
Expand Down Expand Up @@ -164,15 +165,6 @@ def pick_profile_name(
args_profile_name: Optional[str],
project_profile_name: Optional[str] = None,
) -> str:
# TODO: Duplicating this method as direct copy of the implementation in dbt.cli.resolvers
# dbt.cli.resolvers implementation can't be used because it causes a circular dependency.
# This should be removed and use a safe default access on the Flags module when
# https://github.com/dbt-labs/dbt-core/issues/6259 is closed.
def default_profiles_dir():
from pathlib import Path

return Path.cwd() if (Path.cwd() / "profiles.yml").exists() else Path.home() / ".dbt"

profile_name = project_profile_name
if args_profile_name is not None:
profile_name = args_profile_name
Expand Down
1 change: 1 addition & 0 deletions core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"console_scripts": ["dbt = dbt.cli.main:cli"],
},
install_requires=[
"appdirs>=1.4.4",
# ----
# dbt-core uses these packages deeply, throughout the codebase, and there have been breaking changes in past patch releases (even though these are major-version-one).
# Pin to the patch or minor version, and bump in each new minor version of dbt-core.
Expand Down
2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ git+https://github.com/dbt-labs/dbt-adapters.git@main
git+https://github.com/dbt-labs/dbt-adapters.git@main#subdirectory=dbt-tests-adapter
git+https://github.com/dbt-labs/dbt-common.git@main
git+https://github.com/dbt-labs/dbt-postgres.git@main
appdirs
# black must match what's in .pre-commit-config.yaml to be sure local env matches CI
black==24.3.0
bumpversion
Expand Down Expand Up @@ -29,6 +30,7 @@ pytest-split
pytest-xdist
sphinx
tox>=3.13
types-appdirs
types-docutils
types-PyYAML
types-Jinja2
Expand Down
Loading