Skip to content

Commit 95e64a9

Browse files
committed
Address notes
1 parent 54a68cc commit 95e64a9

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/rez/package_order.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,10 @@ def refresh(self) -> None:
678678
self.by_package[package] = orderer
679679

680680
if not TYPE_CHECKING:
681+
# Since this class inherits from list it's easier to rely on the type hints coming from
682+
# that base class than to redefine them here, so we hide them by placing them behind
683+
# not TYPE_CHECKING.
684+
681685
def append(self, *args, **kwargs):
682686
self.dirty = True
683687
return super().append(*args, **kwargs)

src/rez/solver.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from contextlib import contextmanager
3030
from enum import Enum
3131
from itertools import product, chain
32-
from typing import Any, Callable, Generator, Iterator, TypeVar, TYPE_CHECKING
32+
from typing import cast, Any, Callable, Generator, Iterator, TypeVar, TYPE_CHECKING
3333
import copy
3434
import time
3535
import sys
@@ -931,8 +931,7 @@ def __str__(self) -> str:
931931
s = "[%s==%s%s]" % (self.package_name, str(variant.version), s_idx)
932932
elif nversions == 1:
933933
entry = self.entries[0]
934-
# we expect all variants to have a non-None index, but filter to satisfy mypy
935-
indexes = sorted([x.index for x in entry.variants if x.index is not None])
934+
indexes = cast("list[int]", sorted([x.index for x in entry.variants]))
936935
s_idx = ','.join(str(x) for x in indexes)
937936
verstr = str(entry.version)
938937
s = "[%s==%s[%s]]" % (self.package_name, verstr, s_idx)

src/rez/version/_requirement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def safe_str(self) -> str:
252252
"""
253253
return str(self)
254254

255-
def conflicts_with(self, other: object) -> bool:
255+
def conflicts_with(self, other: Requirement | VersionedObject) -> bool:
256256
"""Returns True if this requirement conflicts with another :class:`Requirement`
257257
or :class:`VersionedObject`.
258258
@@ -278,7 +278,7 @@ def conflicts_with(self, other: object) -> bool:
278278
else:
279279
return (other.version_ not in self.range_)
280280
else:
281-
return NotImplemented
281+
raise TypeError
282282

283283
def merged(self, other: Requirement) -> Requirement | None:
284284
"""Merge two requirements.

0 commit comments

Comments
 (0)