Skip to content

Commit 96f9958

Browse files
authored
Enable Pyrefly type checking (#3474)
Ref #3473 Description: Enables [Pyrefly](https://github.com/facebook/pyrefly), a fast type checker. I ported the `mypy.ini` file to a `pyrefly.toml` using the `pyrefly init` command and added `# pyrefly: ignore` comments to suppress new type errors. Since this PR already touches a lot of files due to the suppressions, I opted to keep it focused on adding Pyrefly. If it's accepted, I'll follow up with another PR to remove Mypy, update documentation and other references, and clean up easy-to-fix suppressions.
1 parent f400030 commit 96f9958

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+127
-65
lines changed

.github/workflows/typing-checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ jobs:
6464
uv pip install -r requirements-dev.txt
6565
uv pip install .
6666
uv pip install mypy
67+
uv pip install pyrefly
6768
6869
- name: Run MyPy type checking
6970
run: mypy
71+
72+
- name: Run Pyrefly type checking
73+
run: pyrefly check

ignite/contrib/engines/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def _setup_common_distrib_training_handlers(
265265

266266
@trainer.on(Events.EPOCH_STARTED)
267267
def distrib_set_epoch(engine: Engine) -> None:
268+
# pyrefly: ignore [missing-attribute]
268269
train_sampler.set_epoch(engine.state.epoch - 1)
269270

270271

ignite/contrib/engines/tbptt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ def _update(engine: Engine, batch: Sequence[torch.Tensor]) -> float:
117117
return sum(loss_list) / len(loss_list)
118118

119119
engine = Engine(_update)
120+
# pyrefly: ignore [bad-argument-type]
120121
engine.register_events(*Tbptt_Events)
121122
return engine

ignite/contrib/handlers/base_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/base_logger.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

ignite/contrib/handlers/clearml_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/clearml_logger.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

ignite/contrib/handlers/lr_finder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/lr_finder.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

ignite/contrib/handlers/mlflow_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/mlflow_logger.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

ignite/contrib/handlers/neptune_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/neptune_logger.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

ignite/contrib/handlers/param_scheduler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/param_scheduler.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

ignite/contrib/handlers/polyaxon_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
removed_in = "0.6.0"
1010
deprecation_warning = (
1111
f"{__file__} has been moved to /ignite/handlers/polyaxon_logger.py"
12-
+ (f" and will be removed in version {removed_in}" if removed_in else "")
12+
+ f" and will be removed in version {removed_in}"
1313
+ ".\n Please refer to the documentation for more details."
1414
)
1515
warnings.warn(deprecation_warning, DeprecationWarning, stacklevel=2)

0 commit comments

Comments
 (0)