-
Notifications
You must be signed in to change notification settings - Fork 106
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 optional
From Dependency Info in Internal Code
#389
Changes from all commits
50cf43f
08f2292
5e96205
5ee8289
9203c8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
from collections import defaultdict | ||
from textwrap import dedent | ||
from typing import Collection, Dict, List, Mapping, Optional, Sequence, Set, Union | ||
from typing import Any, Collection, Dict, List, Mapping, Optional, Sequence, Set, Union | ||
|
||
import yaml | ||
|
||
|
@@ -35,7 +35,7 @@ def _seperator_munge_get( | |
return d[key.replace("_", "-")] | ||
|
||
|
||
def _apply_categories( | ||
def apply_categories( | ||
requested: Dict[str, Dependency], | ||
planned: Mapping[str, Union[List[LockedDependency], LockedDependency]], | ||
categories: Sequence[str] = ("main", "dev"), | ||
|
@@ -129,12 +129,9 @@ def dep_name(manager: str, dep: str) -> str: | |
targets = [targets] | ||
for target in targets: | ||
target.category = source.category | ||
target.optional = source.optional | ||
|
||
|
||
def parse_conda_lock_file( | ||
path: pathlib.Path, | ||
) -> Lockfile: | ||
def parse_conda_lock_file(path: pathlib.Path) -> Lockfile: | ||
if not path.exists(): | ||
raise FileNotFoundError(f"{path} not found") | ||
|
||
|
@@ -144,6 +141,9 @@ def parse_conda_lock_file( | |
if not (isinstance(version, int) and version <= Lockfile.version): | ||
raise ValueError(f"{path} has unknown version {version}") | ||
|
||
for p in content["package"]: | ||
del p["optional"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: we need to delete the |
||
|
||
return Lockfile.parse_obj(content) | ||
|
||
|
||
|
@@ -207,13 +207,22 @@ def write_section(text: str) -> None: | |
""" | ||
) | ||
|
||
yaml.dump( | ||
{ | ||
"version": Lockfile.version, | ||
**json.loads( | ||
content.json(by_alias=True, exclude_unset=True, exclude_none=True) | ||
), | ||
}, | ||
stream=f, | ||
sort_keys=False, | ||
) | ||
output: Dict[str, Any] = { | ||
"version": Lockfile.version, | ||
"metadata": json.loads( | ||
content.metadata.json( | ||
Comment on lines
+212
to
+213
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just noticed that in #390 you have here instead There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe there was an issue when encoding |
||
by_alias=True, exclude_unset=True, exclude_none=True | ||
) | ||
), | ||
"package": [ | ||
{ | ||
**package.dict( | ||
by_alias=True, exclude_unset=True, exclude_none=True | ||
), | ||
"optional": (package.category != "main"), | ||
} | ||
for package in content.package | ||
], | ||
} | ||
|
||
yaml.dump(output, stream=f, sort_keys=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self:
not p.optional
⇒p.category == "main"
.Since
"main" in categories
, this is redundant and can be deleted.Therefore, this is logically sound.