Skip to content

Commit ac84539

Browse files
authored
Use mamba env export with --json (#2162)
1 parent 918997f commit ac84539

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ repos:
4747
"requests",
4848
"urllib3",
4949
"types-beautifulsoup4",
50-
"types-PyYAML",
5150
"types-requests",
5251
"types-tabulate",
5352
"types-urllib3",

requirements-dev.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,5 @@ pytest-retry
66
# `pytest-xdist` is a plugin that provides the `--numprocesses` flag,
77
# allowing us to run `pytest` tests in parallel
88
pytest-xdist
9-
PyYAML
109
requests
1110
tabulate

tests/package_helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
# SOFTWARE.
2424

25+
import json
2526
import logging
2627
import re
2728
from collections import defaultdict
2829
from itertools import chain
2930
from typing import Any, Optional
3031

31-
import yaml
3232
from docker.models.containers import Container
3333
from tabulate import tabulate
3434

@@ -61,7 +61,7 @@ def start_container(container: TrackedContainer) -> Container:
6161
@staticmethod
6262
def _conda_export_command(from_history: bool) -> list[str]:
6363
"""Return the mamba export command with or without history"""
64-
cmd = ["mamba", "env", "export", "--no-build"]
64+
cmd = ["mamba", "env", "export", "--no-build", "--json"]
6565
if from_history:
6666
cmd.append("--from-history")
6767
return cmd
@@ -96,7 +96,7 @@ def _execute_command(self, command: list[str]) -> str:
9696
@staticmethod
9797
def _parse_package_versions(env_export: str) -> dict[str, set[str]]:
9898
"""Extract packages and versions from the lines returned by the list of specifications"""
99-
dependencies = yaml.safe_load(env_export).get("dependencies")
99+
dependencies = json.loads(env_export).get("dependencies")
100100
# Filtering packages installed through pip
101101
# since we only manage packages installed through mamba here
102102
# They are represented by a dict with a key 'pip'

0 commit comments

Comments
 (0)