Skip to content

Conversation

@deathaxe
Copy link
Member

@deathaxe deathaxe commented Jan 11, 2026

This PR...

  1. updates stubs from ST4202, primarily to be able to run mypy.
  2. updates typehints to a more modern format (AFAIK python 3.9+ format), which is possible due to type hints being excluded from runtime evaluation and type checkers likely running on more modern python.

There are some mypy errors, which may require further investigation about how to fix...

Example:

sublime_lib\view_stream.py:39: error: Self argument missing for a non-static method (or an invalid type for self)  [misc]

Copy link
Member

@FichteFoll FichteFoll left a comment

Choose a reason for hiding this comment

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

Are these the official stubs from the ST distribution?

@deathaxe
Copy link
Member Author

Took original sublime.py and sublime_types.py, modified type hints to more modern format and added additional hints to satisfy mypy. Existing sublime_plugin.pyi was extended by missing classes and methods from official sublime_plugin.py

@FichteFoll
Copy link
Member

Perhaps we should add a mypy job to our PR lint workflow.

@deathaxe deathaxe force-pushed the feat/type-hints branch 2 times, most recently from c44e41c to 60b79f0 Compare January 16, 2026 21:06
@FichteFoll
Copy link
Member

#187 has been merged, so this can be rebased now.

1. typing in sublime.py and sublime_plugin.py was extended to minimize
   linter/mypy warnings.
2. auto-generated stubs via mypy's stubgen script.
3. Merged with existing stubs for EventListeners

- Source files are from ST4202.
- Only public end-points are kept.
  Most internal functions, methods, etc. are removed from stubs.
1. Typing expects python 3.10+ type checker to be used.
2. Runtime code is maintained compatible with python 3.8

Note: Needs some compromises compared to modern py3.13 expectations of typing,
      to maintain compatibility with py3.8
Copy link
Member

@FichteFoll FichteFoll left a comment

Choose a reason for hiding this comment

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

mypy complains about usages of defined_guard, but to get this right we need ParamSpec generics, I believe, and those need Python 3.10+. Can be addressed when we drop 3.8.

@deathaxe
Copy link
Member Author

Any ideas how to solve those warnings are welcome.

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.

3 participants