-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
style: flake8 violation F401 #48185
style: flake8 violation F401 #48185
Conversation
Signed-off-by: fscnick <[email protected]>
@MortalHappiness PTAL |
Signed-off-by: fscnick <[email protected]>
@@ -43,7 +43,7 @@ def matches(self, tags): | |||
class MockProcessRunner: | |||
def __init__(self, fail_cmds=None, cmd_to_callback=None, print_out=False): | |||
self.calls = [] | |||
self.cmd_to_callback = cmd_to_callback or {} # type: Dict[str, Callable] | |||
self.cmd_to_callback: Dict[str, Callable] = cmd_to_callback or {} |
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.
Disclaimer: I am just some random person showing up here.
As the minimum version is now 3.9 and PEP 585 is available. typing.Dict, typing.Callable
and similar are deprecated.
Now we can (and should rather) use from collections.abc import Callable
and the builtins dict instead, if we do not care about backward compatibility
self.cmd_to_callback: Dict[str, Callable] = cmd_to_callback or {} | |
self.cmd_to_callback: dict[str, Callable] = cmd_to_callback or {} |
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're right. However, since our Python worker in CI is still on Python 3.8, we cannot change this now. I'm still waiting for our CI team to upgrade the worker to Python 3.9. Additionally, many places still use typing.Dict
as a type annotation. We can use tools to update it to the new syntax after the Python worker version is upgraded.
Close this because we decide to migrate from |
Why are these changes needed?
While running the pre-commit hook of flake8, the following error occurs if Python version is 3.12. It's because the version of flake8 is too old.
However, there are another violation appeared after removing these unused import.
After taking a look,
nccl_group.py:91 and sampler.py:58 are used in
Optional
autoscaler_test_utils.py:46
Callable
is used in type comment.Thus, suppress F401.
Related issue number
Closes #48062
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.