diff --git a/.changes/unreleased/Fixes-20221030-102114.yaml b/.changes/unreleased/Fixes-20221030-102114.yaml new file mode 100644 index 00000000000..8d50ae2de87 --- /dev/null +++ b/.changes/unreleased/Fixes-20221030-102114.yaml @@ -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" diff --git a/core/dbt/config/project.py b/core/dbt/config/project.py index be86fbde267..99f941933b9 100644 --- a/core/dbt/config/project.py +++ b/core/dbt/config/project.py @@ -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") diff --git a/tests/functional/configs/test_dupe_paths.py b/tests/functional/configs/test_dupe_paths.py index 6170a971142..95b76f5858f 100644 --- a/tests/functional/configs/test_dupe_paths.py +++ b/tests/functional/configs/test_dupe_paths.py @@ -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