Skip to content

fix: fix ty invalid-argument-type#554

Merged
gsprochette merged 9 commits intomainfrom
fix/ty-invalid-argument
Mar 4, 2026
Merged

fix: fix ty invalid-argument-type#554
gsprochette merged 9 commits intomainfrom
fix/ty-invalid-argument

Conversation

@begumcig
Copy link
Member

Description

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Additional Notes

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Comment @cursor review or bugbot run to trigger another review on this PR

sequence=[4, 8],
default_value=8,
meta=dict(desc="Number of bits to use for quantization."),
meta=cast(Mapping[Hashable, Any], dict(desc="Number of bits to use for quantization.")),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing cast() on Boolean meta arguments

Medium Severity

Two Boolean hyperparameter calls still use bare meta=dict(...) without cast(Mapping[Hashable, Any], ...), even though the invalid-argument-type rule was just enabled in pyproject.toml. The sibling file huggingface_llm_int8.py has the exact same Boolean("double_quant", ...) and Boolean("enable_fp32_cpu_offload", ...) calls properly wrapped with cast() (lines 78–85), but these two in huggingface_diffusers_int8.py were missed. This inconsistency will likely cause ty type-check failures now that the rule is enforced.

Fix in Cursor Fix in Web

def split_train_into_train_val_test(dataset: Dataset, seed: int) -> Tuple[Dataset, Dataset, Dataset]:
def split_train_into_train_val_test(
dataset: Dataset | IterableDataset, seed: int
) -> Tuple[Dataset, Dataset, Dataset]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split functions accept IterableDataset but call unsupported method

Medium Severity

The split_train_into_train_val_test, split_train_into_train_val, and split_val_into_val_test functions now accept Dataset | IterableDataset, but their bodies call dataset.train_test_split() which only exists on Dataset, not IterableDataset. Passing an actual IterableDataset would raise an AttributeError at runtime. The callers use cast(Dataset | IterableDataset, ...) which masks the issue, but the widened signatures are misleading and invite future misuse.

Additional Locations (2)

Fix in Cursor Fix in Web

@begumcig begumcig requested a review from gsprochette February 26, 2026 14:07
Copy link
Collaborator

@gsprochette gsprochette left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but this PR needs to wait for #535 to be merged and then re-run ty on version 0.0.18

"""
ds = load_dataset("argmaxinc/librispeech-200", split="train", streaming=False)
ds = ds.map(lambda batch: {"sentence": ""})
ds = cast(Dataset | IterableDataset, ds)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed? I ran ty check with and without this casting and got the same result

from pruna.data.pruna_datamodule import PrunaDataModule
from pruna.evaluation.metrics.aesthetic_laion import AestheticLAION

_ClipModel = Literal[
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be removed because this is adding complexity in tests which we don't type check

@begumcig begumcig force-pushed the fix/ty-invalid-argument branch 4 times, most recently from db237da to bdd01a3 Compare March 4, 2026 10:42
@begumcig begumcig force-pushed the fix/ty-invalid-argument branch from bdd01a3 to 2ff1145 Compare March 4, 2026 10:46
@gsprochette gsprochette merged commit ab078c5 into main Mar 4, 2026
7 checks passed
@gsprochette gsprochette deleted the fix/ty-invalid-argument branch March 4, 2026 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants