Skip to content

[BUG]: cython-lint can miss cross-file inline violations when pre-commit batches files #3246

Closed

Description

@rwgk

Type of bug / component

Silent failure in infrastructure (pre-commit). (This happened to be exposed through ctk-next update 756.)

Description

The cython-lint 0.22.0 hook enabled by #3209 can miss cross-file violations when pre-commit splits files across processes. Its new rule checks for functions declared in a .pxd file but implemented as cdef inline in a .pyx file. The linter keeps declaration/implementation information only within one invocation, so it detects a violation only if both files reach the same process.

Pre-commit partitions its file arguments according to the available CPU count. Consequently, the same code and hook configuration can pass or fail solely because the worker count changes.

Evidence in public code

At public main commit 590a8bf, these three helpers are implemented as cdef inline:

All three have separate declarations in _stream.pxd:31–33. These are exactly the cases the new lint rule should report: placing the implementation in .pyx does not enable cross-module inlining.

The hook configuration does not request serial execution. The rule's cross-file state is local to one invocation.

Reproduction

Using the public commit above, pre-commit 4.7.0, cython-lint 0.22.0, and Cython 3.2.9, actual linter runs over pre-commit's partitions of the 108 eligible Cython files produced:

Workers Placement of _stream.pyx and _stream.pxd Result
2 Same process Fails with all three inline violations
4 Different processes Passes; all three violations are missed

The expected behavior is that both worker counts report the same violations. Changing CPU count or batching should not change which cross-file rules are enforced.

Suggested resolution

  1. Add require_serial: true to the existing cython-lint hook so this file set is checked in one invocation:

    - id: cython-lint
      require_serial: true
      args: [--no-pycodestyle]
      exclude: ^cuda_bindings_(?:12|13)/
      additional_dependencies:
        - Cython==3.2.9
  2. Remove the ineffective inline keyword from the three .pyx definitions. If actual cross-module inlining is desired, move their complete implementations into .pxd instead.

Both changes matter: fixing these three helpers removes the current violations; serial execution addresses the parallel-batching blind spot for the current file set. The underlying cross-file detection behavior is also worth reporting to cython-lint upstream.

Activity

  1. added
    bugSomething isn't working
    on Oct 27, 2026
  2. added theissue type on Oct 27, 2026
  3. assigned and unassigned on Oct 27, 2026
  4. self-assigned this
    on Oct 27, 2026
  5. added a commit that references this issue on Oct 27, 2026
    d05d625
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions