add_pyright_header

Function add_pyright_header 

Source
pub fn add_pyright_header(root: &Path) -> Result<usize>
Expand description

Add Pyright suppression headers to generated Python protobuf files.

This function adds type checker suppression headers to generated _pb2.py and _pb2_grpc.py files. These headers help suppress false positive warnings from type checkers when working with dynamically generated protobuf code that may reference experimental APIs.

§Arguments

  • root - Root directory to recursively scan for protobuf Python files

§Returns

Returns the number of files that were modified with headers.

§Behavior

  • Only modifies files ending with _pb2.py or _pb2_grpc.py
  • Skips files that already have the suppression header
  • Recursively processes all subdirectories
  • Preserves existing file content, only prepending the header

§Header Content

Adds the following header to suppress common type checker issues:

# pyright: reportAttributeAccessIssue=false
# This file is generated by grpcio-tools and may reference grpc.experimental which lacks stubs in types-grpcio.