-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
[mypy] Enable following imports for some directories #6681
[mypy] Enable following imports for some directories #6681
Conversation
👋 Hi! Thank you for contributing to the vLLM project. Once the PR is approved and ready to go, please make sure to run full CI as it is required to merge (or just use auto-merge). To run full CI, you can do one of these:
🚀 |
9833350
to
3696f63
Compare
mypy vllm/transformers_utils --config-file pyproject.toml | ||
mypy vllm/usage --config-file pyproject.toml | ||
mypy vllm/worker --config-file pyproject.toml | ||
mypy tests --follow-imports skip |
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.
the new formatter and github action doesn't pass --config-file, is this intended?
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. The TOML file is already being used by default so there is no need to specify it explicitly.
@@ -94,8 +94,10 @@ def __contains__(self, key: Hashable) -> bool: | |||
def __len__(self) -> int: | |||
return len(self.cache) | |||
|
|||
def __getitem__(self, key: Hashable) -> Optional[T]: | |||
return self.get(key) | |||
def __getitem__(self, key: Hashable) -> T: |
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.
is this related to this PR?
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.
See below.
@@ -109,8 +111,9 @@ def touch(self, key: Hashable) -> None: | |||
def get(self, | |||
key: Hashable, | |||
default_value: Optional[T] = None) -> Optional[T]: | |||
value: Optional[T] |
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.
this doesn't seem to be optional anymore this way?
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.
(iiuc if there's no item, it should raise an exception?)
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, that is the intention so it works more like a Python dictionary. This is required to fix some errors in type annotation where it's obviously expected that the value exists in the cache, such as
Signed-off-by: Alvant <[email protected]>
The
follow_imports
option has been enabled for the following files and directories:vllm/*.py
(originally failedmypy
, made passing in this PR)vllm/adapter_commons
(originally failedmypy
, made passing in this PR)vllm/assets
vllm/inputs
vllm/logging
vllm/multimodal
vllm/platforms
vllm/server
vllm/transformers_utils
(originally failedmypy
, made passing in this PR)vllm/triton_utils
(originally failedmypy
, made passing in this PR)vllm/usage
Future code modifying those files and directories will thus be subject to stricter type checks - another step towards fulfilling #3680.
Note that the config in
pyproject.toml
has been updated such thatfollow_imports
is now enabled by default, but only checks the above directories. After updating another directory to pass withfollow_imports
enabled, please add a corresponding entry inpyproject.toml
then in turn remove it fromformat.sh
andmypy.yaml
.