-
-
Notifications
You must be signed in to change notification settings - Fork 971
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
Make typing_extensions optional. #3990
Make typing_extensions optional. #3990
Conversation
646b2b6
to
396d762
Compare
Codecov Report
@@ Coverage Diff @@
## master #3990 +/- ##
==========================================
- Coverage 90.60% 90.50% -0.11%
==========================================
Files 167 167
Lines 13111 13119 +8
==========================================
- Hits 11879 11873 -6
- Misses 1232 1246 +14
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
I removed |
I don't think this is a blocker of this PR, but I found that $ python -c "import optuna"
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/importlib_metadata/_compat.py", line 9, in <module>
from typing import Protocol
ImportError: cannot import name 'Protocol'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
...
File "/proj/optuna/storages/_rdb/storage.py", line 27, in <module>
from optuna.storages._rdb.models import TrialValueModel
File "/proj/optuna/storages/_rdb/models.py", line 8, in <module>
from sqlalchemy import asc
...
File "/usr/local/lib/python3.6/site-packages/importlib_metadata/_meta.py", line 1, in <module>
from ._compat import Protocol
File "/usr/local/lib/python3.6/site-packages/importlib_metadata/_compat.py", line 11, in <module>
from typing_extensions import Protocol # type: ignore
ModuleNotFoundError: No module named 'typing_extensions' The reproducible code is as follows:
$ git clone https://github.com/c-bata/optuna.git -b make-typing-extensions-optional
$ cd optuna
$ MINOR_VERSION=7
$ docker run -it --rm -v $(pwd):/proj --workdir=/proj python:3.$MINOR_VERSION bash
$ python --version
$ pip install -U pip
$ pip install .
$ python -c "import optuna"
$ pip freeze | grep typing
$ pip uninstall typing-extensions
$ python -c "import optuna" The results are shown in the following table:
|
With this PR, we can use
|
@toshihikoyanase Thank you for your review!
Even though Optuna's RDBStorage users may bump into this problem, I don't think |
I agree with you. With this PR, the |
Actually, it indirectly depends on
And also, |
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.
LGTM.
…ional Make typing_extensions optional.
…ional Make typing_extensions optional.
[Backport] Merge pull request #3990 from c-bata/make-typing-extensions-optional
Motivation
An alternative approach for #3980 to fix
typing_extensions
related issues.Description of the changes
Check the
typing.TYPE_CHECKING
flag to check if type checking is enabled.