Skip to content

Commit 00a0436

Browse files
committed
Address additional type issues; Scope intentional type ignores
1 parent c0a1c3f commit 00a0436

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/lsst/cmservice/common/panda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def refresh_panda_token(url: str, data: dict[str, str]) -> str | None:
7171
os.environ["PANDA_AUTH_ID_TOKEN"] = config.panda.id_token
7272
# - update token expiry
7373
decoded_token = decode_id_token(config.panda.id_token)
74-
config.panda.token_expiry = float(decoded_token["exp"]) # type: ignore
74+
config.panda.token_expiry = float(decoded_token["exp"]) # type: ignore[assignment]
7575
if TYPE_CHECKING:
7676
# the validation machinery of the pyantic field handles conversion
7777
# from float to datetime.
@@ -126,7 +126,7 @@ def get_panda_token() -> str | None:
126126
try:
127127
if config.panda.token_expiry is None:
128128
decoded_token = decode_id_token(config.panda.id_token)
129-
config.panda.token_expiry = float(decoded_token["exp"]) # type: ignore
129+
config.panda.token_expiry = float(decoded_token["exp"]) # type: ignore[assignment]
130130
if TYPE_CHECKING:
131131
# the validation machinery of the pyantic field handles conversion
132132
# from float to datetime.

src/lsst/cmservice/db/row.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,24 @@ async def get_rows(
8383
parent_class = kwargs.get("parent_class")
8484

8585
q = select(cls)
86-
# FIXME: Being a mixin leads to loose typing here.
87-
# Is there a better way?
8886
if hasattr(cls, "parent_id"):
87+
# FIXME All of these tests assert that parent_class is not None
88+
# otherwise it would raise an AttributeError; the constraint
89+
# might as well be satisfied by the first id matching without
90+
# also evaluating additional options. If the gimmick is that
91+
# the method can be invoked with one of parent_id, _name, or
92+
# the parent class, it is invalidated by the fact that
93+
# parent_class is used in all three cases, so defining any of
94+
# the others adds no value.
95+
if TYPE_CHECKING:
96+
assert parent_class is not None
8997
if parent_class is not None:
90-
q = q.where(parent_class.id == cls.parent_id) # type: ignore
98+
parent_id_ = getattr(cls, "parent_id")
99+
q = q.where(parent_class.id == parent_id_)
91100
if parent_name is not None:
92-
q = q.where(parent_class.fullname == parent_name) # type: ignore
101+
q = q.where(parent_class.fullname == parent_name)
93102
if parent_id is not None:
94-
q = q.where(parent_class.id == parent_id) # type: ignore
103+
q = q.where(parent_class.id == parent_id)
95104
q = q.offset(skip).limit(limit)
96105
results = await session.scalars(q)
97106
return results.all()

tests/common/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def test_config_datetime() -> None:
7474
assert config.panda.token_expiry is None
7575

7676
# test validation and coercion on assignment
77-
config.panda.token_expiry = 1740147265 # type: ignore
77+
config.panda.token_expiry = 1740147265 # type: ignore[assignment]
7878
assert isinstance(config.panda.token_expiry, datetime)
7979
assert config.panda.token_expiry.tzinfo is UTC
8080

0 commit comments

Comments
 (0)