Skip to content

Conversation

siddhaka
Copy link
Contributor

This PR refactors llmcompressor/core/lifecycle.py for improved readability, consistency, and adherence to modern Python style conventions.

Copy link

👋 Hi! Thank you for contributing to llm-compressor. Please add the ready label when the PR is ready for review.

Note: This is required to complete the testing suite, please only add the label once the PR is code complete and local testing has been performed.

Copy link
Contributor

Summary of Changes

Hello @siddhaka, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on modernizing the type hints within the llmcompressor/core/lifecycle.py file. By adopting native generic types and the union operator for optional types, the changes enhance code readability, consistency, and maintainability, bringing the codebase in line with contemporary Python best practices.

Highlights

  • Modernized Type Hints: Updated type hints throughout llmcompressor/core/lifecycle.py to use native generic types (e.g., list instead of typing.List) and the union operator (|) for optional types (e.g., Type | None instead of typing.Optional[Type]), aligning with PEP 585 and PEP 604.
  • Refined Imports: Removed List and Optional imports from the typing module as they are no longer necessary with the adoption of modern type hinting syntax.
  • Code Readability: Improved the formatting of a multi-line assert statement for better readability and adherence to modern Python style conventions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR does a good job of modernizing the type hints in llmcompressor/core/lifecycle.py by using the | operator for optional types and built-in collection types like list. The changes improve readability and align with modern Python conventions. I have one suggestion regarding a docstring that could be made more accurate.

@rahul-tuli
Copy link
Collaborator

Hi @siddhaka, thank you for your contribution, it seems like both #1933 and #1934 changed alot more files than scoped in the PR description, I'm guessing it's due to styling changes, However we would like to keep the PRs crisp, could you rebase the diff on latest main, and limit the changes to intended files, for example if you wanted to change llmcompressor/core/lifecycle please limit the changes to just that file. Kindly let us know if we can help in any way, the diff looks good otherwise

@siddhaka siddhaka force-pushed the lifecycle-modernization branch from 0a08e48 to b4fd1b5 Compare October 15, 2025 15:16
@siddhaka
Copy link
Contributor Author

I’ve now cleaned up both PRs to include only the intended updates. Please let me know if any further changes are required.

@rahul-tuli rahul-tuli added the ready When a PR is ready for review label Oct 15, 2025
Copy link
Collaborator

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks for the contribution

@kylesayrs
Copy link
Collaborator

Thanks for the contribution! I have one small nit that I think this worth discussing

From https://docs.python.org/3/library/typing.html#typing.Optional:

On the other hand, if an explicit value of None is allowed, the use of Optional is appropriate, whether the argument is optional or not. For example:

I understand that functionally, Optional and X | None are equivalent, but this comment in the docs (and my personal intuition on the word) suggest that Optional should refer to when the argument is not required to be provided, whereas X | None refers to when the argument must be provided, but could be None.

@rahul-tuli
Copy link
Collaborator

Thanks for the contribution! I have one small nit that I think this worth discussing

From https://docs.python.org/3/library/typing.html#typing.Optional:

On the other hand, if an explicit value of None is allowed, the use of Optional is appropriate, whether the argument is optional or not. For example:

I understand that functionally, Optional and X | None are equivalent, but this comment in the docs (and my personal intuition on the word) suggest that Optional should refer to when the argument is not required to be provided, whereas X | None refers to when the argument must be provided, but could be None.

@kylesayrs would you be kind enough to update #1927 to make this more explicit

Copy link
Collaborator

@rahul-tuli rahul-tuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good nit found by @kylesayrs that we'd like to adopt

kylesayrs
kylesayrs previously approved these changes Oct 16, 2025
Copy link
Collaborator

@kylesayrs kylesayrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Either Optional or X | None is fine.

rahul-tuli
rahul-tuli previously approved these changes Oct 16, 2025
@rahul-tuli rahul-tuli dismissed stale reviews from kylesayrs and themself via 1f09f3b October 16, 2025 17:32
@rahul-tuli rahul-tuli force-pushed the lifecycle-modernization branch from b4fd1b5 to 1f09f3b Compare October 16, 2025 17:32
@rahul-tuli rahul-tuli enabled auto-merge (squash) October 16, 2025 17:34
@rahul-tuli rahul-tuli merged commit 6a71591 into vllm-project:main Oct 16, 2025
9 checks passed
zhanglei1172 pushed a commit to zhanglei1172/llm-compressor that referenced this pull request Oct 17, 2025
…roject#1934)

This PR refactors llmcompressor/core/lifecycle.py for improved
readability, consistency, and adherence to modern Python style
conventions.

---------

Co-authored-by: Rahul Tuli <[email protected]>
Signed-off-by: LeiZhang <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready When a PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants