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

Remove trailing slashes from source paths (#6102) #6179

Merged
merged 4 commits into from
Feb 21, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20221030-102114.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Remove trailing slashes from source paths (#6102)
time: 2022-10-30T10:21:14.660221Z
custom:
Author: jmg-duarte
Issue: "6102"
PR: "6179"
9 changes: 4 additions & 5 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ def _all_source_paths(
analysis_paths: List[str],
macro_paths: List[str],
) -> List[str]:
# We need to turn a list of lists into just a list, then convert to a set to
# get only unique elements, then back to a list
return list(
set(list(chain(model_paths, seed_paths, snapshot_paths, analysis_paths, macro_paths)))
)
paths = chain(model_paths, seed_paths, snapshot_paths, analysis_paths, macro_paths)
# Strip trailing slashes since the path is the same even though the name is not
stripped_paths = map(lambda s: s.rstrip("/"), paths)
return list(set(stripped_paths))


T = TypeVar("T")
Expand Down
24 changes: 24 additions & 0 deletions tests/functional/configs/test_dupe_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,27 @@ def test_config_with_dupe_paths(self, project, dbt_project_yml):
assert len(results) == 1
results = run_dbt(["run"])
assert len(results) == 1


class TestDupeStrippedProjectPaths:
@pytest.fixture(scope="class")
def models(self):
return {
"my_model.sql": my_model_sql,
"seed.csv": seed_csv,
"somedoc.md": somedoc_md,
"schema.yml": schema_yml,
}

@pytest.fixture(scope="class")
def project_config_update(self):
return {
"model-paths": ["models/"],
"seed-paths": ["models"],
}

def test_config_with_dupe_paths(self, project, dbt_project_yml):
results = run_dbt(["seed"])
assert len(results) == 1
results = run_dbt(["run"])
assert len(results) == 1