Skip to content

Fix type checker errors#9

Merged
adsharma merged 2 commits intomainfrom
fix-pyright-re-cffi
May 29, 2025
Merged

Fix type checker errors#9
adsharma merged 2 commits intomainfrom
fix-pyright-re-cffi

Conversation

@adsharma
Copy link
Collaborator

No description provided.

The `lib` object in `src/stdlib/re.py` is created via `cffi.FFI().dlopen()`.
Pyright, as a static analyzer, cannot detect the attributes (`free`, `free_matches`)
that CFFI adds dynamically at runtime from the C library.

This commit adds `# pyright: ignore [reportAttributeAccessIssue]` comments
to the lines where these C functions are accessed through the `lib` object.
This silences the false positive errors reported by pyright, acknowledging
that these attributes are indeed available when the code executes.
Updates the pyright-specific ignore comments to the more generic
`# type: ignore[attr-defined]` for broader compatibility with
different type checkers.

This addresses the false positive errors from static analyzers
that cannot detect attributes dynamically added by CFFI at runtime.
The `[attr-defined]` code is suitable for Mypy and also
recognized by Pyright for this kind of attribute access issue.
@adsharma adsharma merged commit bed7c7f into main May 29, 2025
2 checks passed
@adsharma adsharma deleted the fix-pyright-re-cffi branch May 29, 2025 00:37
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.

1 participant