Skip to content

Fix #56: NameError when expand_attribute_column=False#68

Merged
iskandr merged 1 commit into
masterfrom
fix/56-expand-attribute-column-false-nameerror
May 13, 2026
Merged

Fix #56: NameError when expand_attribute_column=False#68
iskandr merged 1 commit into
masterfrom
fix/56-expand-attribute-column-false-nameerror

Conversation

@iskandr
Copy link
Copy Markdown
Contributor

@iskandr iskandr commented May 13, 2026

Summary

`read_gtf(..., expand_attribute_column=False)` raised `NameError: name 'result_df' is not defined` because the else branch did:

```python
result_df = parse_gtf(result_df, features=features)
```

— referencing `result_df` on the right-hand side before it had been assigned. The branch was untested, which is why the bug survived. Fixed by passing the actual input (`filepath_or_buffer`) and threading `split_attributes=False` so the unexpanded path doesn't emit the `attribute_split` helper column the caller didn't ask for.

Bumps to 2.7.1.

Closes #56.

Test plan

  • `./lint.sh` clean
  • `./test.sh` — 59 passed, coverage 95% overall, `read_gtf.py` at 96%
  • New `tests/test_expand_attribute_column_false.py` covers:
    • pandas / polars / dict result types preserve the raw `attribute` column
    • per-key attribute columns (`gene_name` etc.) are NOT produced
    • `attribute_split` helper column is NOT produced
    • `features` filter still applies
    • `attribute_aliases` and `cast_version_columns` are graceful no-ops on the unexpanded frame

The else branch in read_gtf passed `result_df` to parse_gtf before
`result_df` had been assigned — a guaranteed NameError that survived
because the branch was never tested. Replaced with the correct
`filepath_or_buffer` argument and also pass `split_attributes=False`
so the unexpanded path doesn't emit the helper `attribute_split` column
the user didn't ask for.

Added tests/test_expand_attribute_column_false.py covering pandas /
polars / dict result types, the features filter, and the alias /
version-cast kwargs as graceful no-ops when attribute columns aren't
expanded.

Bumped to 2.7.1.
@coveralls
Copy link
Copy Markdown

Coverage Report for CI Build 25819115218

Coverage increased (+1.4%) to 95.215%

Details

  • Coverage increased (+1.4%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 2 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

2 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
read_gtf.py 2 95.97%

Coverage Stats

Coverage Status
Relevant Lines: 209
Covered Lines: 199
Line Coverage: 95.22%
Coverage Strength: 0.95 hits per line

💛 - Coveralls

@iskandr iskandr merged commit d2fc051 into master May 13, 2026
8 checks passed
@iskandr iskandr deleted the fix/56-expand-attribute-column-false-nameerror branch May 13, 2026 18:53
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.

result_df does not exist when setting expand_attribute_column=False

2 participants