Fix pyrefly type errors and modernize type hints in LR scheduler classes#3500
Fix pyrefly type errors and modernize type hints in LR scheduler classes#3500
Conversation
Co-authored-by: vfdev-5 <[email protected]>
Co-authored-by: vfdev-5 <[email protected]>
Co-authored-by: vfdev-5 <[email protected]>
|
@copilot ignite/handlers/lr_finder.py:13-17 just import Also change the old typing to the new typing everywhere in the file. For example: |
…tax in lr_finder.py Co-authored-by: vfdev-5 <[email protected]>
Done in commit 8d4f2ab.
|
|
@copilot Great! |
Co-authored-by: vfdev-5 <[email protected]>
Done in commit e068938. Modernized all type hints in param_scheduler.py to Python 3.10+ syntax:
|
Typing Fixes for pyrefly errors ✅
Original Issues (All Fixed)
_ExponentialLR.base_lrsassignment type issue (lr_finder.py:543)_ExponentialLR.get_lr()return type to match parent class (lr_finder.py:545)_ExponentialLR.get_lr()list comprehension return type (lr_finder.py:548)_CosineAnnealingWarmRestarts.get_lr()return type (param_scheduler.py:900)LRScheduler.get_param()return type for single element (param_scheduler.py:998)LRScheduler.get_param()return type for multiple elements (param_scheduler.py:1000)Additional Improvements
LRSchedulerdirectly from torch.optim.lr_scheduler (no try/except)PyTorchLRScheduleralias to avoid naming conflict with ignite's LRSchedulerUnion[A, B]→A | BOptional[A]→A | NoneList[T]→list[T]Dict[K, V]→dict[K, V]Tuple[T, ...]→tuple[T, ...]Changes Made
lr_finder.py:
from torch.optim.lr_scheduler import LRScheduler as PyTorchLRSchedulerclass _ExponentialLR(_LRScheduler)→class _ExponentialLR(PyTorchLRScheduler)Dict,List,Optional,Unionparam_scheduler.py:
Dict,List,Optional,Union,Tupleint | Noneandlist[torch.Tensor | float]for_CosineAnnealingWarmRestarts.get_lr()torch.Tensor | float | list[torch.Tensor | float]forLRScheduler.get_param()Verification
Result
All typing errors resolved with comprehensive modernization of type hints to Python 3.10+ syntax throughout both files, following project conventions established in PR #3497.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.