Repository navigation
[python-package] use dataclass for CallbackEnv - #6048
Merged
Merged
Conversation
jameslamb
marked this pull request as ready for review
August 18, 2023 04:10
jameslamb
requested review from
guolinke,
jmoralez and
shiyu1994
as code owners
August 18, 2023 04:10
jmoralez
approved these changes
Aug 21, 2023
Member
Author
Collaborator
|
No worries. I forgot about that pip package as well haha |
Contributor
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Contributes #3756.
Contributes to #3867.
Proposes converting
CallbackEnvin the Python package to a dataclass.Also proposes removing uses of
import collectionsin favor of importing only exactly what LightGBM needs from that module.Restating the benefits I mentioned when I last tried this in #5765,
dataclassesare preferable tonamedtuplein the following ways:mypyto understand the expected types of properties@property(just like normal classes)I realized today that "use
dataclassses" and "drop Python 3.6 support" don't have to be coupled... I was wrong to suggest that coupling in #5765 and #6022 (comment).This proposes taking on the
dataclassespackage as a required dependency only for Python 3.6. For details on that mechanism, see PEP 508 and PEP 631:That package still exists on PyPI exactly for cases like this... it's intended to be used to continue to provide
dataclassessupport for Python 3.6: https://pypi.org/project/dataclasses/.