Skip to content

Commit b3cdd41

Browse files
authored
Ignore conda venv from source files (#580)
1 parent cca1bcf commit b3cdd41

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

lean/components/util/project_manager.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def get_source_files(self, directory: Path) -> List[Path]:
137137
if (obj.name in reserved_names + output_reserved_names or
138138
obj.name.startswith(".") or
139139
# ignore python virtual environments
140-
(obj / "pyvenv.cfg").is_file()):
140+
(obj / "pyvenv.cfg").is_file() or
141+
(obj / "conda-meta").is_dir()
142+
):
141143
continue
142144

143145
source_files.extend(self.get_source_files(obj))

tests/components/util/test_project_manager.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_get_source_files_ignores_python_virtual_environments(directory: str) ->
164164
project_path = Path.cwd() / "My Project"
165165
project_path.mkdir()
166166

167-
files = [project_path / "main.py", project_path / directory / "pyvenv.cfg"]
167+
files = [project_path / "main.py", project_path / directory / "script.py", project_path / directory / "pyvenv.cfg"]
168168
for file in files:
169169
file.parent.mkdir(parents=True, exist_ok=True)
170170
file.touch()
@@ -174,6 +174,24 @@ def test_get_source_files_ignores_python_virtual_environments(directory: str) ->
174174

175175
assert files_to_sync == [files[0]]
176176

177+
@pytest.mark.parametrize("directory", ["conda", "my_conda"])
178+
def test_get_source_files_ignores_conda_virtual_environment(directory: str) -> None:
179+
project_path = Path.cwd() / "My Project"
180+
project_path.mkdir()
181+
182+
main_file = project_path / "main.py"
183+
main_file.parent.mkdir(parents=True, exist_ok=True)
184+
main_file.touch()
185+
186+
conda_meta_dir = project_path / directory / "conda-meta"
187+
conda_meta_dir.mkdir(parents=True, exist_ok=True)
188+
conda_script_file = project_path / directory / "script.py"
189+
conda_script_file.touch()
190+
191+
project_manager = _create_project_manager()
192+
files_to_sync = project_manager.get_source_files(project_path)
193+
194+
assert files_to_sync == [main_file]
177195

178196
def test_update_last_modified_time_updates_file_properties() -> None:
179197
local_file = Path.cwd() / "file.txt"

0 commit comments

Comments
 (0)