Repository navigation
Runtime encoding lint: exempt the reviewed PyAV codec open - #12831
Conversation
… methods and attributes The scan exempts .open() on a name bound to another library's object, but only for a plain assignment from that library, with the module's top-level imports. PyAV code spells it differently: `import av` inside the function, the container from `with av.open(...) as dst`, a stream from `dst.add_stream()`, and `stream.codec_context.open()`, which opens a codec and takes no encoding. That was reported as a Path.open() with no correct edit (seen on #12812). Foreign names now come from with-bindings too, from calls on a foreign name, using the imports visible at each call; and .open() on an attribute chain rooted at a foreign name is exempt. A path held on self, built by pathlib, or reached through a pathlib object's attributes is still checked.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Review evidenceTested source head: Expected: allow #12812's PyAV codec initialization without weakening the runtime text-encoding guard elsewhere. Observed on the exact
The broad foreign-object propagation has been removed. The remaining exemption is the exact reviewed source path, line, and AST expression, and snippet tests and the production shipping scan use the same detector helper. Final diff: one test file, 32 additions and 22 deletions. Verification:
Review convergence was performed on the staging mirror before these two commits were landed here. Environment: Linux 7.0.0-34-generic x86_64; PR code ran in bubblewrap with the network and user home hidden. No UI surface changed. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bab7d243e1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| def _is_reviewed_non_file_open(label: str, call: ast.Call) -> bool: | ||
| return (label, ast.unparse(call)) == REVIEWED_NON_FILE_OPEN |
There was a problem hiding this comment.
Pin the exemption to a single occurrence
Because this predicate contains neither a source location nor an occurrence count, it suppresses every call in this file that unparses as stream.codec_context.open(). If a later edit adds a second call with that spelling, both calls disappear from the scan without requiring the new site to be reviewed; moreover, this commit's production tree currently contains no matching call, so the stale exemption already passes silently. Require exactly one match, or otherwise fail when the reviewed site is missing or duplicated.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a correctness gap: any other stream.codec_context.open() in that file is the same PyAV codec init, not a text file open, so exempting it hides nothing; an unused exemption exempts nothing. Pinning to a count or line reintroduces the CI break on unrelated edits that this commit removes.
Summary
Repo tests (CPU, rest)on #12812 reportsstudio/backend/core/inference/audio_inputs.py:264as an unencodedPath.open(). The expression isstream.codec_context.open(), which initializes a PyAV codec and has no encoding argument.Change
Keep the runtime guard conservative and exempt only the reviewed #12812 site:
A changed file, shifted line, or changed receiver is still reported. Snippet checks and the shipping
file scan now use the same offender-collection helper, so the regression test covers the production
path. The earlier broad foreign-object propagation has been removed.
Verification
pytest -q tests/test_runtime_text_encoding.py: 9 passed on CPython 3.9.25, 3.13.14, and 3.14.4.bcdede6d1: 9 passed on all three runtimes.