Skip to content

Commit

Permalink
Minor documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Oct 12, 2022
1 parent ee591da commit 3c154ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ In your `.pre-commit-config.yaml`, add:

```yaml
- repo: https://github.com/tdegeus/conda_envfile
rev: v0.1.0
rev: v0.2.1
hooks:
- id: conda_envfile_parse
files: "environment.yaml"
Expand All @@ -41,7 +41,7 @@ Combine different version restrictions. For example:
```python
import conda_envfile
conda_envfile.unique("foo >1.2.0", "foo =1.2.*")
list(map(str, conda_envfile.unique("foo >1.2.0", "foo =1.2.*")))
```

which returns
Expand Down
33 changes: 23 additions & 10 deletions conda_envfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,28 @@
class VersionRange:
"""
Specify the most restrictive version range.
If you overwrite properties are add version ranges only the most restrictive range will be kept
(a ``ValueError`` will be raised if the new range is not compatible with the existing one).
* Modification of properties only leads to a change if the new value is more restrictive.
For example::
>>> vr = VersionRange(less="2.0")
>>> vr.less_equal = "1.0"
>>> print(vr)
"<=1.0"
while::
>>> vr = VersionRange(less="2.0")
>>> vr.less_equal = "3.0"
>>> print(vr)
"<2.0"
* Merging two ranges to the most restrictive is done using ``+``::
>>> a = VersionRange(less="2.0")
>>> b = VersionRange(greater="1.0")
>>> print(a + b)
">1.0, <2.0"
"""

def __init__(
Expand Down Expand Up @@ -422,14 +442,7 @@ def _interpret(dependency: str) -> dict:
Interpret a version string.
:param dependency: Dependency specifier.
:return: Dictionary::
name # name of the dependency
wildcard # wildcard version specifier (if used)
= # precise version (if used)
>= # version range (if used)
> # version range (if used)
<= # version range (if used)
< # version range (if used)
:return: Dictionary with keys 'name', 'range', and optionally 'wildcard', 'build'.
"""

if dependency is None:
Expand Down

0 comments on commit 3c154ab

Please sign in to comment.