Skip to content

chore: make python quality expectations explicit#17446

Open
dmcilvaney wants to merge 3 commits into
microsoft:4.0from
dmcilvaney:damcilva/4.0/pipelines/add_python_lint
Open

chore: make python quality expectations explicit#17446
dmcilvaney wants to merge 3 commits into
microsoft:4.0from
dmcilvaney:damcilva/4.0/pipelines/add_python_lint

Conversation

@dmcilvaney
Copy link
Copy Markdown
Contributor

@dmcilvaney dmcilvaney commented May 26, 2026

Note: This does not include actual fixes for the detected issues, it just runs the auto-formatter (i.e. basic fixes like whitespace, no actual code changes).

There are known and expected lint failures across all files. Future developers are expected to validate the auto-fix changes when they save a file and gradually address linter findings.

A summary of current outstanding detections:

Totals

Tool Files scanned Errors Auto-fixable (safe) Auto-fixable (unsafe)
ruff (lint) 31 377 47 45
pyright (type) 33 168

Top ruff rules

Count Rule Description Fixable
30 D103 undocumented public function
23 TRY003 long exception message
21 EM102 f-string in exception
18 S101 use of assert
14 ANN001 missing function arg type
14 D102 undocumented public method
13 PLR2004 magic value comparison
12 C901 complex structure
12 D205 missing blank line after summary
11 UP045 Optional[X]X | None
10 FBT001 bool positional arg
9 I002 missing from __future__ import annotations
9 PTH123 builtin open vs Path.open
8 BLE001 blind except
8 INP001 implicit namespace package
8 PTH118 os.path.join vs pathlib
7 D212 docstring summary placement
7 PLR0912 too many branches
6 each D209, FBT002/003, PERF401, PLR0911/0913/0915, PLW1510, PTH112, S310 (misc style / complexity / subprocess / urlopen / pathlib) partial

Long tail (~80 more rules): missing return annotations, ambiguous names, commented-out code, etc. Full list: ruff check --statistics.

Pyright rules

Count Rule
51 reportUnknownParameterType
47 reportMissingTypeArgument
26 reportArgumentType
12 reportUntypedFunctionDecorator
10 reportMissingParameterType
9 reportMissingImports
5 reportReturnType
5 reportAttributeAccessIssue
2 reportInvalidTypeForm
1 reportCallIssue

Top files

Ruff Pyright File
81 39 scripts/repo/synthesize-repodata.py
51 scripts/mcps/fedora-distgit-mcp.py
39 2 .github/workflows/scripts/spec-review/spec_review_schema.py
23 4 .github/workflows/scripts/locks-check/post_locks_comment.py
20 23 .github/workflows/scripts/control-tower/client.py
16 4 .github/workflows/scripts/render-specs-check/post_render_comment.py
14 1 scripts/update-components-list.py
14 2 .github/workflows/scripts/control-tower/run_prcheck.py
11 scripts/repo/_repo_layout.py
11 2 .github/workflows/scripts/control-tower/run_package_build.py
10 2 base/images/tests/utils/pytest_plugin.py
10 11 .github/workflows/scripts/render-specs-check/check_rendered_specs.py
9 13 .github/workflows/scripts/spec-review/create_check_annotations.py
8 23 base/images/tests/conftest.py
8 2 .github/workflows/scripts/spec-review/format_pr_comment.py
7 1 scripts/mcps/koji-mcp.py
7 1 base/images/tests/cases/vm-base/test_kernel.py
5 6 .github/workflows/scripts/components/compute_render_set.py
3 2 scripts/mcps/_mcp_utils.py
2 27 base/images/tests/utils/extract.py

(Remaining files have < 5 detections each.)

Reproduce

ruff check --statistics
ruff check --output-format=concise | awk -F: 'NF>1 {print $1}' | sort | uniq -c | sort -rn
pyright --outputjson | jq '.summary, .generalDiagnostics | length'

Copilot AI review requested due to automatic review settings May 26, 2026 23:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes Python code quality expectations explicit for the repo by adding Ruff/Pyright configuration and editor defaults, and then reformatting a set of Python files to match the formatter’s output.

Changes:

  • Added repository-level Python tooling configs (ruff.toml, pyrightconfig.json) and a base .editorconfig.
  • Updated VS Code workspace settings + recommended extensions to standardize formatting/linting behavior.
  • Applied automated formatting to multiple Python scripts (repo tooling, image tests, workflow helper scripts).

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/repo/synthesize-repodata.py Formatter-only reflow to match the chosen Python formatting rules.
scripts/repo/_repo_layout.py Formatter-only reflow of dataclass fields and constant definitions.
ruff.toml Introduces Ruff lint/format expectations for the repo.
pyrightconfig.json Introduces Pyright type-checking expectations for the repo.
base/images/tests/utils/tools.py Formatter-only reflow for readability/line-length.
base/images/tests/utils/pytest_plugin.py Formatter-only reflow of comprehensions/strings.
base/images/tests/utils/extract.py Formatter-only reflow of command lists and logging calls.
base/images/tests/utils/disk.py Formatter-only reflow of logging call arguments.
base/images/tests/conftest.py Formatter-only reflow of fixture signatures and logging.
base/images/tests/cases/vm-base/test_partitions.py Formatter-only reflow of assertion message formatting.
base/images/tests/cases/test_packages.py Formatter-only reflow of test function signature.
.vscode/settings.json Adds workspace-wide formatting/linting behavior and Python-specific settings.
.vscode/mcps/koji-mcp.py Formatter-only reflow for long lines/prints.
.vscode/mcps/fedora-distgit-mcp.py Formatter-only reflow for long lines and argument lists.
.vscode/mcps/_mcp_utils.py Formatter-only reflow of a multi-line print(...).
.vscode/extensions.json Recommends extensions aligned with the new Python tooling setup.
.github/workflows/scripts/spec-review/spec_review_schema.py Formatter-only reflow for long lines and argument lists.
.github/workflows/scripts/spec-review/format_pr_comment.py Formatter-only reflow for long lines and argument lists.
.github/workflows/scripts/spec-review/create_check_annotations.py Formatter-only reflow for dict literals and CLI arg parsing.
.github/workflows/scripts/components/compute_render_set.py Formatter-only reflow of dict.fromkeys(...) construction.
.editorconfig Adds baseline editor normalization (LF, trim whitespace, final newline).

Comment thread pyrightconfig.json Outdated
Comment thread .vscode/settings.json Outdated
Comment thread ruff.toml
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/add_python_lint branch from 01eb727 to 795be6a Compare May 27, 2026 00:09
Copy link
Copy Markdown
Member

@reubeno reubeno left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! Just a couple of quick comments, but I'm very supportive.

Looking at all the Python utility code, I'd also suggest we should look at creating proper Python packages that we maintain in other repos and reference/install in workflows here. We can discuss that offline...

Comment thread .vscode/settings.json Outdated
Comment thread pyrightconfig.json
Comment thread pyrightconfig.json Outdated
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/add_python_lint branch from 1192b12 to 9bc62fc Compare May 28, 2026 23:46
@dmcilvaney dmcilvaney requested a review from Copilot May 28, 2026 23:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 34 out of 36 changed files in this pull request and generated 2 comments.

Comment thread ruff.toml
Comment thread .vscode/settings.json Outdated
@dmcilvaney dmcilvaney force-pushed the damcilva/4.0/pipelines/add_python_lint branch from 9bc62fc to e1e6365 Compare May 29, 2026 00:41
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.

3 participants