-
Notifications
You must be signed in to change notification settings - Fork 448
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
Fix duplicated imports #1133
Fix duplicated imports #1133
Conversation
f99736d
to
762e6a0
Compare
762e6a0
to
f2c5f37
Compare
All star-imports are removed.
|
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 @c-bata !
/lgtm
/cc @gaocegege
from pkg.suggestion.v1alpha3.internal.search_space import * | ||
from pkg.suggestion.v1alpha3.internal.trial import * | ||
from pkg.suggestion.v1alpha3.internal.search_space import ( | ||
INTEGER, DOUBLE, CATEGORICAL, DISCRETE, MAX_GOAL, |
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.
Can we do this in a better way to look more clean? we might have more constants. May be wrap this?
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.
You mean that you want to import all constants, right?
Another solution is to define __all__
attribute like this revision. But as the discussion of #1133 (comment), it is known as an anti-pattern in Python.
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.
@c-bata What do you think about creating file: constant.py
under /internal/
folder ?
And insert all constant there? I think it will be easier to have all constant in one file
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.
It sounds good 👍 @johnugeorge What do you think?
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.
Yes. SGTM
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: johnugeorge The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Avoid star-imports * Add constants
What this PR does / why we need it:
__init__.py
to avoid using namespace package.__all__
attribute.logging
is imported at L3 and used at L8. But Jetbrains IDE highlightsimport logging
as gray. This means it is an unused line. The reason why it is highlighted as gray is using star imports (from pkg.suggestion.v1alpha3.internal.search_space import *
andfrom pkg.suggestion.v1alpha3.internal.trial import *
).To avoid this problem, I define__all__
attribute. See https://docs.python.org/3/tutorial/modules.html#importing-from-a-packageWhich issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):None
Special notes for your reviewer:
None
Release note: