Skip to content

[None][doc] Update Python coding guidelines.#12439

Merged
QiJune merged 1 commit intoNVIDIA:mainfrom
hnover-nv:coding_guidelines_python
Mar 25, 2026
Merged

[None][doc] Update Python coding guidelines.#12439
QiJune merged 1 commit intoNVIDIA:mainfrom
hnover-nv:coding_guidelines_python

Conversation

@hnover-nv
Copy link
Copy Markdown
Collaborator

@hnover-nv hnover-nv commented Mar 23, 2026

Description

Update Python coding guidelines, to better match both current and desired usage.

The most noteworthy changes are

  • Removal of requirement to maintain full import paths.
  • Guidelines on typing.

Test Coverage

None

PR Checklist

Please review the following before submitting your PR:

  • PR description clearly explains what and why. If using CodeRabbit's summary, please make sure it makes sense.

  • PR Follows TRT-LLM CODING GUIDELINES to the best of your knowledge.

  • Test cases are provided for new code paths (see test instructions)

  • Any new dependencies have been scanned for license and vulnerabilities

  • CODEOWNERS updated if ownership changes

  • Documentation updated as needed

  • Update tava architecture diagram if there is a significant design change in PR.

  • The reviewers assigned automatically/manually are appropriate for the PR.

  • [ x ] Please check this after reviewing the above items as appropriate for this PR.

GitHub Bot Help

To see a list of available CI bot commands, please comment /bot help.

Summary by CodeRabbit

Documentation

  • Updated Python coding guidelines with clarified formatting standards, enhanced import requirements (linter-driven ordering, wildcard restrictions, __all__ maintenance), and refined naming conventions for constants, non-public identifiers, and device/host container objects.
  • Expanded guidance for docstrings, error handling, and introduced comprehensive static typing rules with type annotation expectations and best practices.

@hnover-nv hnover-nv force-pushed the coding_guidelines_python branch from cbd25d8 to a6d3e29 Compare March 23, 2026 06:12
@hnover-nv hnover-nv marked this pull request as ready for review March 23, 2026 06:15
@hnover-nv hnover-nv requested a review from a team as a code owner March 23, 2026 06:15
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Python section of CODING_GUIDELINES.md was reorganized and expanded, replacing indentation guidance with broader formatting rules, updating import and naming conventions, adding non-public identifier prefixing guidance, expanding documentation and error-handling expectations, and introducing comprehensive static typing guidelines.

Changes

Cohort / File(s) Summary
CODING_GUIDELINES.md
CODING_GUIDELINES.md
Reorganized Python formatting guidance; replaced indentation rules with automatic tooling expectations; added linter-driven import ordering and __all__ requirements; refined local variable naming to allow single-letter uppercase and k_ prefix convention; consolidated global variables into "Constants (any scope)" rule; introduced host/device identifier suffixes; expanded documentation, error-handling, and attribute docstring guidance; added comprehensive "Static Typing" subsection covering opt-in rules, type annotations, Callable, Literal, @overload, TypeVar, and Protocol guidance.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title '[None][doc] Update Python coding guidelines.' is directly related to the changeset, which updates the Python section of CODING_GUIDELINES.md with revised formatting, import, naming, error-handling, and typing guidance.
Description check ✅ Passed The PR description follows the repository template structure with sections for Description, Test Coverage, and PR Checklist. It explains the main changes (removal of full import path requirement and addition of typing guidelines) and appropriately marks Test Coverage as 'None' since this is a documentation-only change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CODING_GUIDELINES.md`:
- Line 455: Summary: The document uses “doc strings” in one place but the
project style uses “docstrings” consistently. Fix: replace the phrase “doc
strings” with “docstrings” in the sentence that currently reads “Externally
called functions should have doc strings, and their arguments should be
documented.” to match the rest of the document’s terminology; ensure any nearby
occurrences in the same paragraph also use “docstrings” consistently.
- Line 526: Update the prose to hyphenate the terms by changing the phrase
"Static type checking at pre-commit time is opt in by submodule PICs" to "Static
type checking at pre-commit time is opt-in by submodule PICs" and ensure any
occurrences of "built in" are changed to "built-in"; apply the same hyphenation
to the related occurrence referenced as "Also applies to: 538-538" so both
instances use "opt-in" and "built-in" consistently throughout the sentence(s).
- Around line 533-536: The example for class Foo is malformed because an
embedded control character merged the class and __init__ lines; fix by removing
the control character and placing "class Foo:" and "def __init__(self, x: int)
-> None:" on separate lines with proper indentation, ensure the assignment lines
use correct indentation for self.x and self.y, and add "from typing import
Optional" at the top of the example if Optional is not already imported so the
annotation on y: Optional[int] is valid.
- Line 357: The formatting note contains mismatched quotation marks: the phrase
“legacy” files and “new" files mixes a smart opening quote with a straight
closing quote; update the sentence so both quoted words use matching quotes
(e.g., change “new" files to “new” files or convert both to straight quotes
"legacy" and "new") to ensure consistent quotation in the sentence containing
“legacy” files and “new" files and the reference to <pyproject.toml>.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: dd351aad-a8fb-4750-95f4-595c3ad917c6

📥 Commits

Reviewing files that changed from the base of the PR and between 124746e and a6d3e29.

📒 Files selected for processing (1)
  • CODING_GUIDELINES.md

Signed-off-by: Harris Nover <249353502+hnover-nv@users.noreply.github.com>
@hnover-nv hnover-nv force-pushed the coding_guidelines_python branch from a6d3e29 to 72588fb Compare March 23, 2026 19:57
@hnover-nv
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #39972 [ run ] triggered by Bot. Commit: 72588fb Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #39972 [ run ] completed with state SUCCESS. Commit: 72588fb
/LLM/main/L0_MergeRequest_PR pipeline #31134 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@hnover-nv
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #39984 [ run ] triggered by Bot. Commit: 72588fb Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #39984 [ run ] completed with state SUCCESS. Commit: 72588fb
/LLM/main/L0_MergeRequest_PR pipeline #31144 completed with status: 'FAILURE'

CI Report

⚠️ Action Required:

  • Please check the failed tests and fix your PR
  • If you cannot view the failures, ask the CI triggerer to share details
  • Once fixed, request an NVIDIA team member to trigger CI again

Link to invocation

@hnover-nv
Copy link
Copy Markdown
Collaborator Author

/bot run

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40032 [ run ] triggered by Bot. Commit: 72588fb Link to invocation

@tensorrt-cicd
Copy link
Copy Markdown
Collaborator

PR_Github #40032 [ run ] completed with state SUCCESS. Commit: 72588fb
/LLM/main/L0_MergeRequest_PR pipeline #31187 completed with status: 'SUCCESS'

CI Report

Link to invocation

Copy link
Copy Markdown
Collaborator

@QiJune QiJune left a comment

Choose a reason for hiding this comment

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

LGTM

@QiJune QiJune merged commit ba8b3d8 into NVIDIA:main Mar 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants