-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[python-package] fix mypy typing discrepancies in basic.py #5731
[python-package] fix mypy typing discrepancies in basic.py #5731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
For some of these proposed changes, I'll wait to review them until the other in-progress mypy
and type hinting PRs that are currently open have been approved and merged.
For the changes about pointers...I'm nervous about taking a runtime dependency on things from ctypes
which are prefixed with _
, like ctypes._CData
. If those things are removed in future releases of ctypes
, import lightgbm
will fail. That risk is not acceptable for the benefit of slightly more specific type hints.
What do you think about the approach I've proposed in #5729, to use string literals for such things to avoid runtime import errors in that situation?
@IdoKendo are you still interested in pursuing this PR? If so, please see me comment above about using string literals for hints like If not (or if you'd prefer to work on something else), just let me know and I'll continue addressing these particular |
@jameslamb Unfortunately, not sure I have the capacity at this time, I'll close this PR so you can address it, and hopefully, soon I can get back to helping more. |
ok no problem! Thanks so much for all your help so far, you've really helped re-invigorate this type annotation project that we'd been neglecting for a bit. Would love to have you come back and contribute any time. |
This pull request has been automatically locked since there has not been any recent activity since it was closed. |
Contributes to #3867.
mypy
currently raises the following errors inbasic.py
file:These errors occur due to missing type annotations in the code and lack of
None
type validations.This PR proposes fixing these errors by adding the missing annotations and
None
type checks.Notes for Reviewers
This was tested by running mypy as documented in #3867.