Skip to content

Commit 66e34a8

Browse files
authored
docs(specifiers): add is_unsatisfiable() usage example (#1166)
* docs(specifiers): add is_unsatisfiable() usage example * docs(specifiers): add compound SpecifierSet & is_unsatisfiable example Per review feedback from @henryiii and @notatallshaw, adds a compound example using the & operator to show how combining two SpecifierSets can produce an unsatisfiable set — closer to how users actually build specifiers from requires-python plus other constraints.
1 parent 02c1e95 commit 66e34a8

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

docs/specifiers.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ Usage
4949
>>> # contained within our specifier.
5050
>>> list(combined_spec.filter([v1, v2, "1.4"]))
5151
[<Version('1.0')>, '1.4']
52+
>>> # We can check if a specifier set can never be satisfied
53+
>>> SpecifierSet(">=2.0,<1.0").is_unsatisfiable()
54+
True
55+
>>> SpecifierSet(">=1.0,<2.0").is_unsatisfiable()
56+
False
57+
>>> # Compound sets built with ``&`` may also become unsatisfiable
58+
>>> (SpecifierSet(">=3.9,<4.0") & SpecifierSet("==3.12.*")).is_unsatisfiable()
59+
False
60+
>>> (SpecifierSet(">=3.13,<4.0") & SpecifierSet("==3.12.*")).is_unsatisfiable()
61+
True
5262

5363

5464
Reference

0 commit comments

Comments
 (0)