Skip to content

Commit ffeb2ea

Browse files
committed
tests
1 parent 7f32112 commit ffeb2ea

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

.actions/assistant.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@
4646

4747

4848
class _RequirementWithComment(Requirement):
49-
strict_string = "# strict"
49+
strict_cmd = "strict"
5050

5151
def __init__(self, *args: Any, comment: str = "", pip_argument: Optional[str] = None, **kwargs: Any) -> None:
5252
super().__init__(*args, **kwargs)
5353
self.comment = comment
5454
assert pip_argument is None or pip_argument # sanity check that it's not an empty str
5555
self.pip_argument = pip_argument
56-
self.strict = self.strict_string in comment.lower()
56+
self.strict = self.strict_cmd in comment.lower()
5757

5858
def adjust(self, unfreeze: str) -> str:
5959
"""Remove version restrictions unless they are strict.
@@ -62,25 +62,26 @@ def adjust(self, unfreeze: str) -> str:
6262
'arrow<=1.2.2,>=1.2.0'
6363
>>> _RequirementWithComment("arrow<=1.2.2,>=1.2.0", comment="# strict").adjust("none")
6464
'arrow<=1.2.2,>=1.2.0 # strict'
65-
>>> _RequirementWithComment("arrow<=1.2.2,>=1.2.0", comment="# my name").adjust("all")
66-
'arrow>=1.2.0'
65+
>>> _RequirementWithComment('arrow<=1.2.2,>=1.2.0; python_version >= "3.10"', comment="# my name").adjust("all")
66+
'arrow>=1.2.0; python_version >= "3.10"'
6767
>>> _RequirementWithComment("arrow>=1.2.0, <=1.2.2", comment="# strict").adjust("all")
6868
'arrow<=1.2.2,>=1.2.0 # strict'
69-
>>> _RequirementWithComment("arrow").adjust("all")
70-
'arrow'
69+
>>> _RequirementWithComment('arrow; python_version >= "3.10"').adjust("all")
70+
'arrow; python_version >= "3.10"'
7171
>>> _RequirementWithComment("arrow>=1.2.0, <=1.2.2", comment="# cool").adjust("major")
7272
'arrow<2.0,>=1.2.0'
7373
>>> _RequirementWithComment("arrow>=1.2.0, <=1.2.2", comment="# strict").adjust("major")
7474
'arrow<=1.2.2,>=1.2.0 # strict'
75-
>>> _RequirementWithComment("arrow>=1.2.0").adjust("major")
76-
'arrow>=1.2.0'
75+
>>> _RequirementWithComment('arrow>=1.2.0; python_version >= "3.10"').adjust("major")
76+
'arrow>=1.2.0; python_version >= "3.10"'
7777
>>> _RequirementWithComment("arrow").adjust("major")
7878
'arrow'
7979
8080
"""
8181
out = str(self)
8282
if self.strict:
83-
return f"{out} {self.strict_string}"
83+
return f"{out} # {self.strict_cmd}"
84+
8485
specs = [(spec.operator, spec.version) for spec in self.specifier]
8586
if unfreeze == "major":
8687
for operator, version in specs:

0 commit comments

Comments
 (0)