Skip to content

Commit bea4779

Browse files
endrebakIsy89Endre Bakken Stovner
authored
Open file fix (#379)
* Fixing ResourceWarning caused by pyranges/readers.py function read_bed line 127 or 129 unclosed file. * logging changes relative to fix #377 and bumping the version number * Fix lint errors. --------- Co-authored-by: isy89 <lazzeri89@gmail.com> Co-authored-by: Endre Bakken Stovner <endre.bakkenstovner@arm.com>
1 parent 131083d commit bea4779

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

CHANGELOG.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.0.132 (07.04.2024) (@Isy89)
2+
- Fix ResourceWarning in pyranges/readers.py function read_bed due to unclosed file. #377
3+
14
# 0.0.131 (04.10.2023) (@fairliereese)
25
- Added option to read_gtf to rename columns that have reserved names in pyranges https://github.com/pyranges/pyranges/issues/341
36

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "pyranges"
7-
version = "0.0.131"
7+
version = "0.0.132"
88
description = "GenomicRanges for Python."
99
readme = "README.md"
1010
authors = [{ name = "Endre Bakken Stovner", email = "endbak@pm.me" },

pyranges/readers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,11 @@ def read_bed(f, as_df=False, nrows=None):
124124
if f.endswith(".gz"):
125125
import gzip
126126

127-
first_start = gzip.open(f).readline().split()[1]
127+
with gzip.open(f) as of:
128+
first_start = of.readline().split()[1]
128129
else:
129-
first_start = open(f).readline().split()[1]
130+
with open(f) as of:
131+
first_start = of.readline().split()[1]
130132

131133
header = None
132134

0 commit comments

Comments
 (0)