Skip to content

Commit d6e6a43

Browse files
authored
[ci] Re-enable fail on warning for pytest pipeline. (#265)
* [ci] Re-enable fail on warning for pytest pipeline. * [Fix] Use sqlite3 context managers in pandas module. * [Fix] Add closing context.
1 parent 8183ee2 commit d6e6a43

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ jobs:
4343
uv pip freeze --system
4444
4545
- name: Run tests
46-
run: pytest --cov=pyerrors -vv
46+
run: pytest --cov=pyerrors -vv -Werror

pyerrors/input/pandas.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import warnings
22
import gzip
33
import sqlite3
4+
from contextlib import closing
45
import pandas as pd
56
from ..obs import Obs
67
from ..correlators import Corr
@@ -29,9 +30,8 @@ def to_sql(df, table_name, db, if_exists='fail', gz=True, **kwargs):
2930
None
3031
"""
3132
se_df = _serialize_df(df, gz=gz)
32-
con = sqlite3.connect(db)
33-
se_df.to_sql(table_name, con, if_exists=if_exists, index=False, **kwargs)
34-
con.close()
33+
with closing(sqlite3.connect(db)) as con:
34+
se_df.to_sql(table_name, con=con, if_exists=if_exists, index=False, **kwargs)
3535

3636

3737
def read_sql(sql, db, auto_gamma=False, **kwargs):
@@ -52,9 +52,8 @@ def read_sql(sql, db, auto_gamma=False, **kwargs):
5252
data : pandas.DataFrame
5353
Dataframe with the content of the sqlite database.
5454
"""
55-
con = sqlite3.connect(db)
56-
extract_df = pd.read_sql(sql, con, **kwargs)
57-
con.close()
55+
with closing(sqlite3.connect(db)) as con:
56+
extract_df = pd.read_sql(sql, con=con, **kwargs)
5857
return _deserialize_df(extract_df, auto_gamma=auto_gamma)
5958

6059

0 commit comments

Comments
 (0)