Skip to content
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

Merged
merged 13 commits into from
Jul 31, 2024

Conversation

DarkLight1337
Copy link
Member

@DarkLight1337 DarkLight1337 commented Jul 23, 2024

The follow_imports option has been enabled for the following files and directories:

  • vllm/*.py (originally failed mypy, made passing in this PR)
  • vllm/adapter_commons (originally failed mypy, made passing in this PR)
  • vllm/assets
  • vllm/inputs
  • vllm/logging
  • vllm/multimodal
  • vllm/platforms
  • vllm/server
  • vllm/transformers_utils (originally failed mypy, made passing in this PR)
  • vllm/triton_utils (originally failed mypy, 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 that follow_imports is now enabled by default, but only checks the above directories. After updating another directory to pass with follow_imports enabled, please add a corresponding entry in pyproject.toml then in turn remove it from format.sh and mypy.yaml.

Copy link

👋 Hi! Thank you for contributing to the vLLM project.
Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which consists a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of default ones by unblocking the steps in your fast-check build on Buildkite UI.

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:

  • Comment /ready on the PR
  • Add ready label to the PR
  • Enable auto-merge.

🚀

@DarkLight1337 DarkLight1337 added the ready ONLY add when PR is ready to merge/full CI is needed label Jul 23, 2024
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
Copy link
Collaborator

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?

Copy link
Member Author

@DarkLight1337 DarkLight1337 Jul 31, 2024

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:
Copy link
Collaborator

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?

Copy link
Member Author

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]
Copy link
Collaborator

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?

Copy link
Collaborator

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?)

Copy link
Member Author

@DarkLight1337 DarkLight1337 Jul 31, 2024

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

https://github.com/vllm-project/vllm/pull/6681/files#diff-b18798a12fb09225d97522a75d725a9244959b92683a1f4f74756d248d5aa10fR98

@DarkLight1337 DarkLight1337 merged commit da1f7cc into vllm-project:main Jul 31, 2024
72 checks passed
@DarkLight1337 DarkLight1337 deleted the mypy-follow-imports branch July 31, 2024 02:38
kylesayrs pushed a commit to neuralmagic/vllm that referenced this pull request Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants