Skip to content

Unify ruff config and apply lint fixes across all sub-repos#1703

Merged
cpcloud merged 42 commits intoNVIDIA:mainfrom
cpcloud:ruff-unification
Mar 3, 2026
Merged

Unify ruff config and apply lint fixes across all sub-repos#1703
cpcloud merged 42 commits intoNVIDIA:mainfrom
cpcloud:ruff-unification

Conversation

@cpcloud
Copy link
Contributor

@cpcloud cpcloud commented Feb 27, 2026

Summary

  • Consolidate ruff configuration into a single top-level ruff.toml, removing the duplicated [tool.ruff] section from cuda_pathfinder/pyproject.toml
  • Enable a comprehensive rule set (E, W, F, UP, B, SIM, I, S, ARG, Q, N, C4, PIE, T20, RUF, PT, DTZ) with sane per-file ignores for tests, examples, benchmarks, and CUDA bindings (which mirror C API naming conventions)
  • Add ruff >=0.15.3 to pixi dependencies
  • Apply all auto-fixable and manual lint fixes, grouped by (category, repo) — see commit log for details

Rule categories applied

Category Description
I001 Import sorting (stdlib → third-party → first-party)
RUF100 Remove stale # noqa comments
C4 Simplify comprehensions (C400, C401, C414, C416, C419, C420)
PIE Misc cleanup (PIE808 unnecessary range start, PIE790 placeholder, PIE810 multiple starts/endswith)
PT Pytest style (PT001 fixture parens, PT003 extraneous scope, PT013 incorrect import, PT022 useless yield)
RUF Ruff-specific (RUF012 mutable class default, RUF013 implicit Optional, RUF022/023 unsorted dunder, RUF059 unused unpack)
E Pycodestyle (E711 none-comparison)
SIM Simplify (SIM102 collapsible-if, SIM105 suppressible-exception)
DTZ Timezone-aware datetime (DTZ011)
N Naming conventions (N801, N806, N816 — suppressed or renamed as appropriate)
ARG Unused arguments (suppressed for interface methods and pytest hooks)
F Pyflakes (F401 — suppressed for intentional re-exports and side-effect imports)
B Bugbear (B018 — suppressed for property access expected to raise)
S Bandit security (S102, S110, S301, S603, S607 — suppressed at each call site)

Config decisions

  • C408 (unnecessary dict/list/tuple call) and RUF005 (collection literal concatenation) are globally disabled — dict() and list + list are fine
  • Import sorting: combine-as-imports is off — aliased imports stay separate from bare imports
  • S rules: All suppressed at the call site with # noqa, not via global/per-file ignores
  • Naming (N): Ignored across cuda_bindings/ since it mirrors C API naming; specific suppressions elsewhere
  • Tests: Broad ignores for T201, ARG, RUF059, F841, E402, E702, N-rules, PT-rules, B028, RUF005, RUF003, RUF043

Closes #1677

Test plan

  • ruff check passes with zero violations
  • ruff format --check passes with zero reformatted files
  • CI passes on all sub-repos

Made with Cursor

@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 27, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Merge cuda_pathfinder's [tool.ruff] into the top-level ruff.toml and
remove the duplicate. The unified config is the union of all lint rules
(adding ARG, Q, N, C4, PIE, T20, RUF, PT, DTZ) with sane per-file
ignores for tests, examples, benchmarks, scripts, and CUDA naming
conventions in cuda_bindings.

Made-with: Cursor
- Remove combine-as-imports (keep as-imports separate from bare imports)
- Add C408 to global ignores (dict()/list()/tuple() calls are fine)
- Add RUF005 to global ignores (list concatenation is fine)
- Add E402, F403, F405 to __init__.py per-file-ignores
- Add E702, B028 to test per-file-ignores
- Add T201 for canary_probe_subprocess.py

Made-with: Cursor
- I001: unsorted imports — 48 fixed across 48 files

Made-with: Cursor
- RUF100: unused-noqa — 80 fixed across 24 files

Made-with: Cursor
- C416: unnecessary-comprehension — use set()/list() directly
- C401: unnecessary-generator-set — use set comprehension
- C419: unnecessary-comprehension-in-call — use generator in all()/any()
- C400: unnecessary-generator-list — use list comprehension
- C414: unnecessary-double-cast-or-process — remove redundant list()
- C420: unnecessary-dict-comprehension — use dict.fromkeys()

40 fixed across 10 files

Made-with: Cursor
- PIE808: unnecessary-range-start — remove redundant range(0, n)
- PIE790: unnecessary-placeholder — remove pass after docstring
- PIE810: multiple-starts-ends-with — consolidate into tuple arg

3 fixed across 3 files

Made-with: Cursor
- PT003: extraneous-scope-function — remove default scope="function"
- PT022: pytest-useless-yield-fixture — convert yield fixture to return
- PT001: pytest-fixture-incorrect-parentheses — remove empty parentheses
- PT013: pytest-incorrect-pytest-import — use pytest.param instead of from pytest import param

18 fixed across 4 files

Made-with: Cursor
- RUF022: unsorted-dunder-all — sort __all__ entries (4 fixes across 4 files)
- RUF023: unsorted-dunder-slots — sort __slots__ entries (3 fixes across 1 file)
- RUF012: mutable-class-default — suppress with noqa for lookup tables (5 fixes in 1 file)

Made-with: Cursor
- E711: none-comparison — use 'is not None' instead of '!= None' (1 fix in 1 file)

Made-with: Cursor
- N806: non-lowercase-variable-in-function — rename CUDA_PATH to cuda_path (2 fixes in 1 file)
- N816: mixed-case-variable-in-global-scope — suppress for CUDA API naming (1 noqa in 1 file)
- N801: invalid-class-name — suppress for setuptools convention (1 noqa in 1 file)

Made-with: Cursor
- ARG002: unused-method-argument — suppress for interface method (1 noqa in 1 file)

Made-with: Cursor
- F401: unused-import — suppress for re-exports and side-effect imports (4 noqa in 2 files)

Made-with: Cursor
- B018: useless-expression — suppress for property access expected to raise (2 noqa in 1 file)

Made-with: Cursor
- S110: try-except-pass — suppress for best-effort cleanup (5 noqa in 2 files)
- S102: exec-builtin — suppress in test code (2 noqa in 2 files)
- S301: suspicious-pickle-usage — suppress in test code (3 noqa in 3 files)

Made-with: Cursor
- I001: unsorted imports — 42 fixed across NFILES files

Made-with: Cursor
- RUF100: unused-noqa — 16 fixed across 9 files

Made-with: Cursor
- C416: unnecessary-comprehension — use set()/list() directly
- C401: unnecessary-generator-set — use set comprehension
- C419: unnecessary-comprehension-in-call — use generator in all()/any()
- C400: unnecessary-generator-list — use list comprehension
- C414: unnecessary-double-cast-or-process — remove redundant list()
- C420: unnecessary-dict-comprehension — use dict.fromkeys()

9 fixed across 3 files

Made-with: Cursor
- PIE808: unnecessary-range-start — remove redundant range(0, n)
- PIE790: unnecessary-placeholder — remove pass after docstring
- PIE810: multiple-starts-ends-with — consolidate into tuple arg

5 fixed across 4 files

Made-with: Cursor
- PT003: extraneous-scope-function — remove default scope="function" (4 fixes)
- PT001: pytest-fixture-incorrect-parentheses — remove empty parentheses

4 fixed across 1 files

Made-with: Cursor
- F401: unused-import — suppress for intentional re-exports and side-effect imports (2 noqa in 2 files)

Made-with: Cursor
- S110: try-except-pass — suppress for best-effort cleanup (2 noqa in 1 file)
- S603: subprocess-without-shell-equals-true — suppress at call site (5 noqa in 4 files)
- S607: start-process-with-partial-path — suppress at call site (3 noqa in 2 files)

Made-with: Cursor
- RUF100: unused-noqa — 12 fixed across 7 files

Made-with: Cursor
- SIM102: collapsible-if — merge nested if statements (1 fix in 1 file)
- SIM105: suppressible-exception — use contextlib.suppress instead of try/except/pass (1 fix in 1 file)

Made-with: Cursor
- S110: try-except-pass — suppress for best-effort cleanup (1 noqa in 1 file)

Made-with: Cursor
- I001: unsorted imports — across 1 files

Made-with: Cursor
- RUF100: unused-noqa — 1 fixed across 1 files

Made-with: Cursor
- RUF059: unused-unpacked-variable — prefix unused vars with underscore (2 fixes in 1 file)

Made-with: Cursor
- I001: unsorted imports — across 2 files

Made-with: Cursor
- RUF100: unused-noqa — 2 fixed across 1 files

Made-with: Cursor
- DTZ011: call-date-today — use timezone-aware datetime.now(tz=utc) (1 fix in 1 file)

Made-with: Cursor
- N806: non-lowercase-variable-in-function — rename TILE_SIZE to tile_size (1 fix in 1 file)

Made-with: Cursor
- S603: subprocess-without-shell-equals-true — suppress at call site (1 noqa in 1 file)
- S607: start-process-with-partial-path — suppress at call site (1 noqa in 1 file)

Made-with: Cursor
- RUF100: unused-noqa — 1 fixed across 1 files

Made-with: Cursor
- RUF013: implicit-optional — annotate as T | None explicitly (2 fixes in 1 file)

Made-with: Cursor
- S603: subprocess-without-shell-equals-true — suppress at call site (1 noqa in 1 file)

Made-with: Cursor
- ARG001: unused-function-argument — suppress for pytest hook signature (1 noqa in 1 file)

Made-with: Cursor
- 2 files reformatted (cuda_core/cuda/core/system/__init__.py, cuda_core/tests/test_utils.py)

Made-with: Cursor
@copy-pr-bot
Copy link
Contributor

copy-pr-bot bot commented Feb 27, 2026

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

ctypes Structure._fields_ is a standard pattern, not a mutable default concern

Made-with: Cursor
@cpcloud
Copy link
Contributor Author

cpcloud commented Feb 27, 2026

/ok to test

Read CU_MEM_ALLOCATION_TYPE_* from CUmemAllocationType instead of CUmemAccess_flags so cuda.core imports correctly in test/docs CI jobs.

Made-with: Cursor
@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 2, 2026

/ok to test

@github-actions

This comment has been minimized.

Switch test parametrization calls to pytest.param so collection succeeds under current pytest and the pixi cuda_core suite runs end-to-end.

Made-with: Cursor
@cpcloud
Copy link
Contributor Author

cpcloud commented Mar 2, 2026

/ok to test

@cpcloud cpcloud merged commit eabaf4b into NVIDIA:main Mar 3, 2026
86 checks passed
@cpcloud cpcloud deleted the ruff-unification branch March 3, 2026 16:21
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

Doc Preview CI
Preview removed because the pull request was closed or merged.

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.

Examples: Standardize imports and dependency policy

2 participants