verifiers icon indicating copy to clipboard operation
verifiers copied to clipboard

Plan to improve typing

Open anakin87 opened this issue 5 months ago • 2 comments

Hi @willccbb, thanks for the great project!

I'd like to help improve typing. A few questions before starting:

  1. I noticed many # type: ignore[unresolved-import]. Since contributors are asked to run uv sync --all-extras (we can do the same on CI), most libraries should be available, so we could remove most of these comments. BTW,type: ignore comments cause types from these libraries to be treated as Any, so no type checking. Agree?

  2. liger-kernel requires triton, which cannot be installed on macOS. Slightly related to the previous point, since many contributors might be on macOS, I'd add a conditional dependency: liger-kernel>=0.5.10 ; sys_platform != 'darwin'. WDYT?

  3. Is ty the reference typing tool for this project? If so, can we drop ignores that were only needed for MyPy or Pyright, or do you have other plans?

Once these aspects are clear, I think I can remove some type: ignore and make typing more effective.

anakin87 avatar Sep 24 '25 21:09 anakin87

ah, I should update the contributor guidance -- developing on Mac without the trainer-only extras is totally fine (I often do this myself), but the trainer-related imports won't be resolved (hence the ignores).

don't really plan on having all of the extras become Mac-friendly; proper fix is likely to just add a GPU-based CI for smoke testing that trainer features aren't broken.

as for typing tools, I've been testing out ty in my own workflow but haven't fully dropped pyright from my development setup. ty the only typing tool we're checking in CI for now, I added partly for consistency with some other PI projects; probably will keep some of the other ignores around (sorry) as notes to self to improve typing in various places.

willccbb avatar Sep 28 '25 09:09 willccbb

Thanks for the clarification! I've spent some time experimenting with possible improvements, but it seems difficult to make them fully compatible with the current setup. Still, I wanted to leave a few notes that might be useful for the future.

  1. Installing most dependencies on CI/macOS should be quite feasible and fast. In the long run, this would be a more robust way to check typing.
  2. I still think that excluding liger-kernel on macOS makes sense, so people can run uv sync --all-extras without issues. This way, types can be checked for all compatible libraries. (GPU training tests can run in the CI in the future.)
  3. Since ty and Pyright differ quite a bit, improvements for one can sometimes break the other. Once the project standardizes on a single tool, both locally and in CI (perhaps ty when it's more stable), we'll be able to improve typing more easily.

anakin87 avatar Oct 09 '25 13:10 anakin87