Skip to content

Commit 70f7b1d

Browse files
committed
fix(imports): improve pyright compatibility for helpers and smash
Refactored imports in helpers.py and smash_utils.py to use explicit collections.abc and requests.auth imports. This resolves pyright attribute access issues and improves type hinting compatibility.
1 parent 0073051 commit 70f7b1d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cardano_node_tests/utils/helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import argparse
2-
import collections
32
import contextlib
43
import datetime
54
import functools
@@ -17,6 +16,7 @@
1716
import subprocess
1817
import types as tt
1918
import typing as tp
19+
from collections import abc
2020

2121
import cardano_node_tests.utils.types as ttypes
2222

@@ -291,9 +291,10 @@ def tool_has(command: str) -> bool:
291291

292292
def flatten(
293293
iterable: tp.Iterable,
294-
ltypes: type[tp.Iterable[tp.Any]] = collections.abc.Iterable, # pyright: ignore [reportAttributeAccessIssue]
294+
ltypes: type[tp.Iterable] | None = None,
295295
) -> tp.Generator:
296296
"""Flatten an irregular (arbitrarily nested) iterable of iterables."""
297+
ltypes = ltypes if ltypes is not None else abc.Iterable
297298
remainder = iter(iterable)
298299
while True:
299300
try:

cardano_node_tests/utils/smash_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import typing as tp
77

88
import requests
9+
from requests import auth as rauth
910

1011
from cardano_node_tests.utils import cluster_nodes
1112
from cardano_node_tests.utils import dbsync_queries
@@ -55,11 +56,11 @@ def __init__(self, instance_num: int) -> None:
5556
self.base_url = f"http://localhost:{self.port}"
5657
self.auth = self._get_auth()
5758

58-
def _get_auth(self) -> requests.auth.HTTPBasicAuth | None: # pyright: ignore [reportAttributeAccessIssue]
59+
def _get_auth(self) -> rauth.HTTPBasicAuth | None:
5960
"""Get Basic Auth credentials if configured."""
6061
admin = os.environ.get("SMASH_ADMIN", "admin")
6162
password = os.environ.get("SMASH_PASSWORD", "password")
62-
return requests.auth.HTTPBasicAuth(admin, password) if admin and password else None # pyright: ignore [reportAttributeAccessIssue]
63+
return rauth.HTTPBasicAuth(admin, password) if admin and password else None
6364

6465
def get_pool_metadata(self, pool_id: str, pool_meta_hash: str) -> PoolMetadata:
6566
"""Fetch stake pool metadata from SMASH, returning a `PoolMetadata`."""

0 commit comments

Comments
 (0)