Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ba56a6d
Move test_image_filter.py
garciadias Feb 5, 2025
5216b7a
Merge remote-tracking branch 'origin/dev' into dev
garciadias Feb 12, 2025
eacd783
Merge remote-tracking branch 'origin/dev' into dev
garciadias Feb 14, 2025
c64825f
Merge remote-tracking branch 'upstream/dev' into dev
garciadias Feb 19, 2025
66b6c17
Merge remote-tracking branch 'origin/dev' into dev
garciadias Feb 27, 2025
19cab57
Merge remote-tracking branch 'upstream/dev' into dev
garciadias Apr 11, 2025
4b8086b
feat: replace mypy with ty for static type analysis
garciadias May 22, 2026
763b7ff
fix: restore mypy config and tune ty to match zero-error baseline
garciadias May 22, 2026
ae31bb2
chore: pin ty dev dependency to ty>=0.0.38
garciadias May 22, 2026
42ec9b2
fix: restore --mypy flag alongside --ty in runtests.sh
garciadias May 22, 2026
6cf89d0
Update .github/workflows/pythonapp.yml
garciadias May 29, 2026
b76fd6e
Update .github/workflows/weekly-preview.yml
garciadias May 29, 2026
8c5c242
feat: replace mypy and pytype with pyrefly for static type analysis
garciadias May 29, 2026
0b1017e
chore: remove dead doPytypeFormat variable from runtests.sh
garciadias May 29, 2026
60723b7
fix: run pyrefly without file args to respect project-includes config
garciadias May 29, 2026
3ec99c8
fix: update cron.yml to use --pyrefly instead of deprecated --pytype
garciadias May 29, 2026
29a9cdc
Merge branch 'upstream/dev' into 1760-replace-mypy-with-ty-type-checker
garciadias May 29, 2026
1cb1735
fix(ci): resolve pipeline failures on PR #8868
garciadias Jun 11, 2026
0f77891
fix: add pyrefly to --codeformat shorthand in runtests.sh (PR #8868)
garciadias Jun 11, 2026
1f01a21
DCO Remediation Commit for R. Garcia-Dias <rafaelagd@gmail.com>
garciadias Jun 11, 2026
b36d10d
DCO Remediation Commit for R. Garcia-Dias <rafaelagd@gmail.com>
garciadias Jun 11, 2026
583baed
Merge branch 'dev' of https://github.com/Project-MONAI/MONAI into 176…
garciadias Jun 11, 2026
db377e0
fix: resolve lingering merge conflict markers in workflows and CONTRI…
garciadias Jun 11, 2026
7b0a669
DCO Remediation Commit for R. Garcia-Dias <rafaelagd@gmail.com>
garciadias Jun 11, 2026
f800d21
fix: add least-privilege permissions block to premerge workflow
garciadias Jun 11, 2026
dfb1048
fix: suppress pre-existing pyrefly errors and fix import ordering
garciadias Jun 11, 2026
4514a0a
fix: remove pyrefly ignore comment causing isort failure in config/__…
garciadias Jun 11, 2026
24ddc21
fix: add deprecated rule suppression to pyrefly config
garciadias Jun 11, 2026
d5e50e0
fix: pin setuptools<70 in packaging jobs to keep pkg_resources for Me…
garciadias Jun 11, 2026
36afece
fix: use --no-build-isolation in packaging installs for MetricsReload…
garciadias Jun 11, 2026
8e4bbf1
fix: move pyrefly comments inline to avoid black reformat issues
garciadias Jun 11, 2026
a1dbe27
autofix
garciadias Jun 11, 2026
a526d94
fix: revert formatting change in bundle/utils.py that black rejected
garciadias Jun 11, 2026
d42b78a
fix: revert to torch==2.4.1 on Windows for gloo compat
garciadias Jun 12, 2026
69bd1e6
fix: skip distributed tests on Windows due to gloo backend unavailabi…
garciadias Jun 12, 2026
2e6eec6
fix: remove resurrected pythonapp.yml and dedupe requirements-dev.txt
garciadias Jun 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/cicd_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
opt: ["codeformat", "mypy"] # "pytype" omitted for being essentially deprecated, see #8865
opt: ["codeformat", "pyrefly"]
steps:
- name: Clean unused tools
run: |
Expand All @@ -80,7 +80,7 @@ jobs:
run: |
# clean up temporary files
$(pwd)/runtests.sh --build --clean
# Github actions have multiple cores, so parallelize pytype
# Github actions have multiple cores, so parallelize pylint
$(pwd)/runtests.sh --build --${{ matrix.opt }} -j $(nproc --all)

min-dep: # Test with minumum dependencies installed for different OS, Python, and PyTorch combinations
Expand Down Expand Up @@ -259,7 +259,7 @@ jobs:
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --user --upgrade pip setuptools wheel twine packaging
python -m pip install --user --upgrade pip "setuptools<70" wheel twine packaging
# install the latest pytorch for testing
# however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated
# fresh torch installation according to pyproject.toml
Expand Down Expand Up @@ -291,8 +291,8 @@ jobs:
- name: Install wheel file
working-directory: ${{ steps.mktemp.outputs.tmp_dir }}
run: |
# install from wheel
python -m pip install monai*.whl --extra-index-url https://download.pytorch.org/whl/cpu
# install from wheel (use --no-build-isolation to keep system setuptools with pkg_resources)
python -m pip install monai*.whl --no-build-isolation --extra-index-url https://download.pytorch.org/whl/cpu
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
python -m pip uninstall -y monai
Expand All @@ -302,6 +302,6 @@ jobs:
run: |
for name in *.tar.gz; do break; done
echo $name
python -m pip install ${name}[all] --extra-index-url https://download.pytorch.org/whl/cpu
python -m pip install ${name}[all] --no-build-isolation --extra-index-url https://download.pytorch.org/whl/cpu
python -c 'import monai; monai.config.print_config()' 2>&1 | grep -iv "unknown"
python -c 'import monai; print(monai.__file__)'
2 changes: 1 addition & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ jobs:
python -c "import torch; print(torch.__version__); print('{} of GPUs available'.format(torch.cuda.device_count()))"
python -c 'import torch; print(torch.rand(5,3, device=torch.device("cuda:0")))'
ngc --version
BUILD_MONAI=1 ./runtests.sh --build --coverage --unittests --disttests # unit tests with pytype checks, coverage report
BUILD_MONAI=1 ./runtests.sh --build --coverage --pyrefly --unittests --disttests # unit tests with pyrefly checks, coverage report
BUILD_MONAI=1 ./runtests.sh --build --coverage --net # integration tests with coverage report
coverage xml --ignore-errors
if pgrep python; then pkill python; fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/weekly-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
opt: ["codeformat", "mypy"]
opt: ["codeformat", "pyrefly"]
steps:
- name: Clean unused tools
run: |
Expand Down
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,11 @@ venv.bak/
# mkdocs documentation
/site

# pytype cache
.pytype/

# mypy
.mypy_cache/
# pyrefly cache
.pyrefly_cache/
examples/scd_lvsegs.npz
temp/
.idea/
.dmypy.json

*~

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Please note that, as per PyTorch, MONAI uses American English spelling. This mea
### Preparing pull requests

To ensure the code quality, MONAI relies on several linting tools ([black](https://github.com/psf/black), [isort](https://github.com/timothycrosley/isort), [ruff](https://github.com/astral-sh/ruff)),
static type analysis tools ([mypy](https://github.com/python/mypy), [pytype](https://github.com/google/pytype)), as well as a set of unit/integration tests.
static type analysis tools ([pyrefly](https://github.com/facebook/pyrefly)), as well as a set of unit/integration tests.

This section highlights all the necessary preparation steps required before sending a pull request.
To collaborate efficiently, please read through this section and follow them.
Expand Down
3 changes: 3 additions & 0 deletions monai/apps/auto3dseg/auto_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ def inspect_datalist_folds(self, datalist_filename: str) -> int:

datalist = ConfigParser.load_config_file(datalist_filename)
if "training" not in datalist:
# pyrefly: ignore [unnecessary-type-conversion]
raise ValueError("Datalist files has no training key:" + str(datalist_filename))

fold_list = [int(d["fold"]) for d in datalist["training"] if "fold" in d]
Expand Down Expand Up @@ -790,6 +791,7 @@ def _train_algo_in_nni(self, history: list[dict[str, Any]]) -> None:
nni_config_filename = os.path.abspath(os.path.join(self.work_dir, f"{name}_nni_config.yaml"))
ConfigParser.export_config_file(nni_config, nni_config_filename, fmt="yaml", default_flow_style=None)

# pyrefly: ignore [redundant-cast]
max_trial = min(self.hpo_tasks, cast(int, default_nni_config["maxTrialNumber"]))
cmd = "nnictl create --config " + nni_config_filename + " --port 8088"

Expand All @@ -805,6 +807,7 @@ def _train_algo_in_nni(self, history: list[dict[str, Any]]) -> None:
n_trainings = len(import_bundle_algo_history(self.work_dir, only_trained=True))

cmd = "nnictl stop --all"
# pyrefly: ignore [bad-argument-type]
run_cmd(cmd.split(), check=True)
logger.info(f"NNI completes HPO on {name}")
last_total_tasks = n_trainings
Expand Down
1 change: 1 addition & 0 deletions monai/apps/auto3dseg/bundle_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ def infer(self, image_file):
config_dir = os.path.join(self.output_path, "configs")
configs_path = [os.path.join(config_dir, f) for f in os.listdir(config_dir)]

# pyrefly: ignore [implicit-import]
spec = importlib.util.spec_from_file_location("InferClass", infer_py)
infer_class = importlib.util.module_from_spec(spec) # type: ignore
sys.modules["InferClass"] = infer_class
Expand Down
1 change: 1 addition & 0 deletions monai/apps/auto3dseg/ensemble_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ def __init__(self, history: Sequence[dict[str, Any]], data_src_cfg_name: str | N
self.ensemble: AlgoEnsemble
self.data_src_cfg = ConfigParser(globals=False)

# pyrefly: ignore [unnecessary-type-conversion]
if data_src_cfg_name is not None and os.path.exists(str(data_src_cfg_name)):
self.data_src_cfg.read_config(data_src_cfg_name)

Expand Down
3 changes: 3 additions & 0 deletions monai/apps/deepedit/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ def _randomize(self, d, key_label):
else:
logger.info(f"Not slice IDs for label: {key_label}")
sid = None
# pyrefly: ignore [unsupported-operation]
self.sid[key_label] = sid

def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.ndarray]:
Expand Down Expand Up @@ -561,6 +562,7 @@ def __init__(
self.guidance: dict[str, list[list[int]]] = {}

def randomize(self, data=None):
# pyrefly: ignore [unsupported-operation]
probability = data[self.probability]
self._will_interact = self.R.choice([True, False], p=[probability, 1.0 - probability])

Expand Down Expand Up @@ -885,6 +887,7 @@ def _randomize(self, d, key_label):
else:
logger.info(f"Not slice IDs for label: {key_label}")
sid = None
# pyrefly: ignore [unsupported-operation]
self.sid[key_label] = sid

def __call__(self, data: Mapping[Hashable, np.ndarray]) -> dict[Hashable, np.ndarray]:
Expand Down
1 change: 1 addition & 0 deletions monai/apps/deepgrow/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def _save_data_2d(vol_idx, vol_image, vol_label, dataset_dir, relative_path):
continue

# For all Labels
# pyrefly: ignore [missing-attribute]
unique_labels = np.unique(label.flatten())
unique_labels = unique_labels[unique_labels != 0]
unique_labels_count = max(unique_labels_count, len(unique_labels))
Expand Down
1 change: 1 addition & 0 deletions monai/apps/deepgrow/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def __init__(self, guidance: str = "guidance", discrepancy: str = "discrepancy",
self._will_interact = None

def randomize(self, data=None):
# pyrefly: ignore [unsupported-operation]
probability = data[self.probability]
self._will_interact = self.R.choice([True, False], p=[probability, 1.0 - probability])

Expand Down
2 changes: 2 additions & 0 deletions monai/apps/detection/networks/retinanet_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ def forward(
)

# 4. Generate anchors and store it in self.anchors: List[Tensor]
# pyrefly: ignore [bad-argument-type]
self.generate_anchors(images, head_outputs)
# num_anchor_locs_per_level: List[int], list of HW or HWD for each level
num_anchor_locs_per_level = [x.shape[2:].numel() for x in head_outputs[self.cls_key]]
Expand All @@ -535,6 +536,7 @@ def forward(
# reshape to Tensor sized(B, sum(HWA), self.num_classes) for self.cls_key
# or (B, sum(HWA), 2* self.spatial_dims) for self.box_reg_key
# A = self.num_anchors_per_loc
# pyrefly: ignore [bad-argument-type]
head_outputs[key] = self._reshape_maps(head_outputs[key])

# 6(1). If during training, return losses
Expand Down
4 changes: 4 additions & 0 deletions monai/apps/detection/transforms/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,14 @@ def __call__(self, boxes: NdarrayTensor, src_spatial_size: Sequence[int] | int |
diff = od - zd
half = abs(diff) // 2
if diff > 0: # need padding (half, diff - half)
# pyrefly: ignore [bad-index, unsupported-operation]
zoomed_boxes[:, axis] = zoomed_boxes[:, axis] + half
# pyrefly: ignore [bad-index, unsupported-operation]
zoomed_boxes[:, axis + spatial_dims] = zoomed_boxes[:, axis + spatial_dims] + half
elif diff < 0: # need slicing (half, half + od)
# pyrefly: ignore [bad-index, unsupported-operation]
zoomed_boxes[:, axis] = zoomed_boxes[:, axis] - half
# pyrefly: ignore [bad-index, unsupported-operation]
zoomed_boxes[:, axis + spatial_dims] = zoomed_boxes[:, axis + spatial_dims] - half
return zoomed_boxes

Expand Down
2 changes: 2 additions & 0 deletions monai/apps/detection/transforms/box_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ def flip_boxes(
_flip_boxes: NdarrayTensor = boxes.clone() if isinstance(boxes, torch.Tensor) else deepcopy(boxes) # type: ignore[assignment]

for axis in flip_axes:
# pyrefly: ignore [bad-index, unsupported-operation]
_flip_boxes[:, axis + spatial_dims] = spatial_size[axis] - boxes[:, axis] - TO_REMOVE
# pyrefly: ignore [bad-index, unsupported-operation]
_flip_boxes[:, axis] = spatial_size[axis] - boxes[:, axis + spatial_dims] - TO_REMOVE

return _flip_boxes
Expand Down
1 change: 1 addition & 0 deletions monai/apps/detection/transforms/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,7 @@ def __call__(self, data: Mapping[Hashable, torch.Tensor]) -> list[dict[Hashable,
cropper = SpatialCrop(roi_center=tuple(center), roi_size=self.spatial_size)
crop_start = [max(s.start, 0) for s in cropper.slices]
crop_end = [min(s.stop, image_size_a) for s, image_size_a in zip(cropper.slices, image_size)]
# pyrefly: ignore [unnecessary-type-conversion]
crop_slices = [slice(int(s), int(e)) for s, e in zip(crop_start, crop_end)]

# crop images
Expand Down
1 change: 1 addition & 0 deletions monai/apps/detection/utils/hard_negative_sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def get_num_neg(self, negative: torch.Tensor, num_pos: int) -> int:
number of negative samples
"""
# always assume at least one pos sample was sampled
# pyrefly: ignore [unnecessary-type-conversion]
num_neg = int(max(1, num_pos) * abs(1 - 1.0 / float(self.positive_fraction)))
# protect against not enough negative examples and sample at least self.min_neg if possible
num_neg = min(negative.numel(), max(num_neg, self.min_neg))
Expand Down
2 changes: 2 additions & 0 deletions monai/apps/generation/maisi/networks/autoencoderkl_maisi.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ def forward(self, x: torch.Tensor) -> torch.Tensor:

# update padding length if necessary
padding = 3
# pyrefly: ignore [unsupported-operation]
if padding % self.stride > 0:
# pyrefly: ignore [unsupported-operation]
padding = (padding // self.stride + 1) * self.stride
if self.print_info:
logger.info(f"Padding size: {padding}")
Expand Down
2 changes: 2 additions & 0 deletions monai/apps/nnunet/nnunetv2_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
tqdm, has_tqdm = optional_import("tqdm", name="tqdm")
nib, _ = optional_import("nibabel")

# pyrefly: ignore [implicit-import]
logger = monai.apps.utils.get_logger(__name__)

__all__ = ["nnUNetV2Runner"]
Expand Down Expand Up @@ -274,6 +275,7 @@ def convert_dataset(self):
modality = [modality]

create_new_dataset_json(
# pyrefly: ignore [bad-argument-type]
modality=modality,
num_foreground_classes=num_foreground_classes,
num_input_channels=num_input_channels,
Expand Down
5 changes: 5 additions & 0 deletions monai/apps/nnunet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
tqdm, has_tqdm = optional_import("tqdm", name="tqdm")
nib, _ = optional_import("nibabel")

# pyrefly: ignore [implicit-import]
logger = monai.apps.utils.get_logger(__name__)

__all__ = ["analyze_data", "create_new_data_copy", "create_new_dataset_json", "NNUNETMode"]
Expand All @@ -43,6 +44,7 @@ def analyze_data(datalist_json: dict, data_dir: str) -> tuple[int, int]:
datalist_json: original data list .json (required by most monai tutorials).
data_dir: raw data directory.
"""
# pyrefly: ignore [implicit-import]
img = monai.transforms.LoadImage(image_only=True, ensure_channel_first=True, simple_keys=True)(
os.path.join(data_dir, datalist_json["training"][0]["image"])
)
Expand All @@ -51,6 +53,7 @@ def analyze_data(datalist_json: dict, data_dir: str) -> tuple[int, int]:

num_foreground_classes = 0
for _i in range(len(datalist_json["training"])):
# pyrefly: ignore [implicit-import]
seg = monai.transforms.LoadImage(image_only=True, ensure_channel_first=True, simple_keys=True)(
os.path.join(data_dir, datalist_json["training"][_i]["label"])
)
Expand Down Expand Up @@ -93,6 +96,7 @@ def create_new_data_copy(
_index += 1

# copy image
# pyrefly: ignore [implicit-import]
nda = monai.transforms.LoadImage(image_only=True, ensure_channel_first=True, simple_keys=True)(
os.path.join(data_dir, orig_img_name)
)
Expand All @@ -105,6 +109,7 @@ def create_new_data_copy(

# copy label
if isinstance(datalist_json[_key][_k], dict) and "label" in datalist_json[_key][_k]:
# pyrefly: ignore [implicit-import]
nda = monai.transforms.LoadImage(image_only=True, ensure_channel_first=True, simple_keys=True)(
os.path.join(data_dir, datalist_json[_key][_k]["label"])
)
Expand Down
2 changes: 2 additions & 0 deletions monai/apps/nuclick/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def bbox(self, patch_size, centroid, size):
x, y = centroid
m, n = size

# pyrefly: ignore [unnecessary-type-conversion]
x_start = int(max(x - patch_size / 2, 0))
# pyrefly: ignore [unnecessary-type-conversion]
y_start = int(max(y - patch_size / 2, 0))
x_end = x_start + patch_size
y_end = y_start + patch_size
Expand Down
1 change: 1 addition & 0 deletions monai/apps/pathology/transforms/post/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ def __call__(self, data):
d = dict(data)
for key in self.key_iterator(d):
offset = d[self.offset_key] if self.offset_key else None
# pyrefly: ignore [bad-argument-type]
centroid = self.converter(d[key], offset)
key_to_add = f"{key}_{self.centroid_key_postfix}"
if key_to_add in d:
Expand Down
2 changes: 2 additions & 0 deletions monai/apps/tcia/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def download_tcia_series_instance(
query_name = "getImageWithMD5Hash" if check_md5 else "getImage"
download_url = f"{BASE_URL}{query_name}?SeriesInstanceUID={series_uid}"

# pyrefly: ignore [implicit-import]
monai.apps.utils.download_and_extract(
url=download_url,
filepath=os.path.join(download_dir, f"{series_uid}.zip"),
Expand All @@ -111,6 +112,7 @@ def download_tcia_series_instance(
raise ValueError("pandas package is necessary, please install it.")
hashes_df = pd.read_csv(os.path.join(output_dir, hashes_filename))
for dcm, md5hash in hashes_df.values:
# pyrefly: ignore [implicit-import]
monai.apps.utils.check_hash(filepath=os.path.join(output_dir, dcm), val=md5hash, hash_type="md5")


Expand Down
4 changes: 4 additions & 0 deletions monai/apps/vista3d/inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ def point_based_window_inferer(
unravel_slice = (
slice(None),
slice(None),
# pyrefly: ignore [unnecessary-type-conversion]
slice(int(lx), int(rx)),
# pyrefly: ignore [unnecessary-type-conversion]
slice(int(ly), int(ry)),
# pyrefly: ignore [unnecessary-type-conversion]
slice(int(lz), int(rz)),
)
batch_image = image[unravel_slice]
Expand Down Expand Up @@ -151,6 +154,7 @@ def _get_window_idx_c(p: int, roi: int, s: int) -> tuple[int, int]:
elif p + roi // 2 > s:
left, right = s - roi, s
else:
# pyrefly: ignore [unnecessary-type-conversion]
left, right = int(p) - roi // 2, int(p) + roi // 2
return left, right

Expand Down
8 changes: 5 additions & 3 deletions monai/apps/vista3d/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ def _convert_name_to_index(name_to_index_mapping: dict, label_prompt: list | Non
for l in label_prompt:
if isinstance(l, (int, str)):
converted_label_prompt.append(
name_to_index_mapping.get(l.lower(), int(l) if l.isdigit() else 0) if isinstance(l, str) else int(l)
name_to_index_mapping.get(l.lower(), int(l) if l.isdigit() else 0)
if isinstance(l, str)
else int(l) # pyrefly: ignore [unnecessary-type-conversion]
)
else:
converted_label_prompt.append(l)
Expand Down Expand Up @@ -208,8 +210,8 @@ def __init__(
self.dataset_key = dataset_key
for name, mapping in label_mappings.items():
self.mappers[name] = MapLabelValue(
orig_labels=[int(pair[0]) for pair in mapping],
target_labels=[int(pair[1]) for pair in mapping],
orig_labels=[int(pair[0]) for pair in mapping], # pyrefly: ignore [unnecessary-type-conversion]
target_labels=[int(pair[1]) for pair in mapping], # pyrefly: ignore [unnecessary-type-conversion]
dtype=dtype,
)

Expand Down
1 change: 1 addition & 0 deletions monai/auto3dseg/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,5 @@ def evaluate(self, data: Any, **kwargs: Any) -> dict:
Args:
data: input data
"""
# pyrefly: ignore [missing-attribute]
return {k: v(data[k], **kwargs).tolist() for k, v in self.data.items() if (callable(v) and k in data)}
1 change: 1 addition & 0 deletions monai/auto3dseg/seg_summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def summarize(self, data: list[dict]) -> dict[str, dict]:

for analyzer in self.summary_analyzers:
if callable(analyzer):
# pyrefly: ignore [missing-attribute]
report.update({analyzer.stats_name: analyzer(data)})

return report
1 change: 1 addition & 0 deletions monai/bundle/reference_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def iter_subconfigs(cls, id: str, config: Any) -> Iterator[tuple[str, str, Any]]
"""
for k, v in config.items() if isinstance(config, dict) else enumerate(config):
sub_id = f"{id}{cls.sep}{k}" if id != "" else f"{k}"
# pyrefly: ignore [invalid-yield]
yield k, sub_id, v

@classmethod
Expand Down
Loading
Loading