Skip to content

Commit fdbf4fa

Browse files
mstonh13
andauthored
chore: Use rtd theme (#63)
* doc: use rtd theme * ci: require that the poetry lock file is up to date (#64) * ci: require that the poetry lock file is up to date * refactor: use pathlib in tests * chore: lock via poetry * chore: update poetry version to 1.5 * fix: add sphinx_rtd_theme and update lock --------- Co-authored-by: Matt Stone <matt@fulcrumgenomics.com> --------- Co-authored-by: Nils Homer <nh13@users.noreply.github.com>
1 parent 22378f0 commit fdbf4fa

File tree

7 files changed

+585
-538
lines changed

7 files changed

+585
-538
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Python package
22

33
on: [push]
44
env:
5-
POETRY_VERSION: 1.2
5+
POETRY_VERSION: 1.5
66

77
jobs:
88
testing:
@@ -45,6 +45,11 @@ jobs:
4545
shell: bash
4646
run: poetry run pip --version >/dev/null 2>&1 || rm -rf .venv
4747

48+
- name: Check that the lock file is up to date
49+
shell: bash
50+
run: |
51+
poetry lock --check
52+
4853
- name: Install deps
4954
shell: bash
5055
run: |

docs/conf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
'sphinx.ext.todo',
3131
'sphinx.ext.ifconfig',
3232
'sphinx.ext.intersphinx',
33-
'sphinx.ext.napoleon']
33+
'sphinx.ext.napoleon',
34+
'sphinx_rtd_theme']
3435

3536
intersphinx_mapping = {'python': ('http://docs.python.org/3.6', None)}
3637

@@ -118,7 +119,7 @@
118119

119120
# The theme to use for HTML and HTML Help pages. Major themes that come with
120121
# Sphinx are currently 'default' and 'sphinxdoc'.
121-
html_theme = 'default'
122+
html_theme = 'sphinx_rtd_theme'
122123

123124
# Theme options are theme-specific and customize the look and feel of a theme
124125
# further. For a list of options available for each theme, see the

fgpyo/fasta/tests/test_builder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from tempfile import NamedTemporaryFile as NamedTemp
55

66
import pytest
7-
from py._path.local import LocalPath as TmpDir
87
from pytest import raises
98

109
from fgpyo.fasta.builder import FastaBuilder
@@ -64,14 +63,14 @@ def test_bases_string_from_ContigBuilder_add(
6463
bases: str,
6564
times: int,
6665
expected: str,
67-
tmpdir: TmpDir,
66+
tmp_path: Path,
6867
) -> None:
6968
"""
7069
Reads bases back from fasta and checks that extra spaces are removed and bases are uppercase
7170
"""
7271
builder = FastaBuilder()
7372
builder.add(name).add(bases, times)
74-
with NamedTemp(suffix=".fa", dir=tmpdir, mode="w", delete=True) as fp:
73+
with NamedTemp(suffix=".fa", dir=tmp_path, mode="w", delete=True) as fp:
7574
builder.to_file(Path(fp.name))
7675
with open(fp.name, "r") as read_fp:
7776
for line in read_fp.readlines():

fgpyo/sam/tests/test_sam.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import pysam
1212
import pytest
13-
from py._path.local import LocalPath as TmpDir
1413
from pysam import AlignmentHeader
1514

1615
import fgpyo.sam as sam
@@ -141,10 +140,10 @@ def test_sam_file_open_writing(
141140
file_type: SamFileType,
142141
expected_records: List[pysam.AlignedSegment],
143142
header_dict: AlignmentHeader,
144-
tmpdir: TmpDir,
143+
tmp_path: Path,
145144
) -> None:
146145
# use header as a keyword argument
147-
with NamedTemp(suffix=file_type.extension, dir=tmpdir, mode="w", delete=False) as fp:
146+
with NamedTemp(suffix=file_type.extension, dir=tmp_path, mode="w", delete=False) as fp:
148147
kwargs = {"header": header_dict}
149148
with sam._pysam_open(
150149
path=fp.file, open_for_reading=False, file_type=file_type, **kwargs # type: ignore
@@ -155,11 +154,13 @@ def test_sam_file_open_writing(
155154

156155

157156
def test_sam_file_open_writing_header_keyword(
158-
expected_records: List[pysam.AlignedSegment], header_dict: AlignmentHeader, tmpdir: TmpDir
157+
expected_records: List[pysam.AlignedSegment],
158+
header_dict: AlignmentHeader,
159+
tmp_path: Path,
159160
) -> None:
160161
# Use SamWriter
161162
# use header as a keyword argument
162-
with NamedTemp(suffix=".sam", dir=tmpdir, mode="w", delete=False) as fp:
163+
with NamedTemp(suffix=".sam", dir=tmp_path, mode="w", delete=False) as fp:
163164
with sam.writer(path=fp.name, header=header_dict, file_type=SamFileType.SAM) as sam_writer:
164165
for r in expected_records:
165166
sam_writer.write(r)

fgpyo/util/tests/test_metric.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import attr
1313
import pytest
14-
from py._path.local import LocalPath as TmpDir
1514

1615
from fgpyo.util.metric import Metric
1716

@@ -139,8 +138,11 @@ class PersonDefault(Metric["PersonDefault"]):
139138

140139

141140
@pytest.mark.parametrize("metric", DUMMY_METRICS)
142-
def test_metric_roundtrip(tmpdir: TmpDir, metric: DummyMetric) -> None:
143-
path: Path = Path(tmpdir) / "metrics.txt"
141+
def test_metric_roundtrip(
142+
tmp_path: Path,
143+
metric: DummyMetric,
144+
) -> None:
145+
path: Path = tmp_path / "metrics.txt"
144146

145147
DummyMetric.write(path, metric)
146148
metrics: List[DummyMetric] = list(DummyMetric.read(path=path))
@@ -149,8 +151,8 @@ def test_metric_roundtrip(tmpdir: TmpDir, metric: DummyMetric) -> None:
149151
assert metrics[0] == metric
150152

151153

152-
def test_metrics_roundtrip(tmpdir: TmpDir) -> None:
153-
path: Path = Path(tmpdir) / "metrics.txt"
154+
def test_metrics_roundtrip(tmp_path: Path) -> None:
155+
path: Path = tmp_path / "metrics.txt"
154156

155157
DummyMetric.write(path, *DUMMY_METRICS)
156158
metrics: List[DummyMetric] = list(DummyMetric.read(path=path))
@@ -173,9 +175,9 @@ def test_metrics_roundtrip_gzip(tmp_path: Path) -> None:
173175
assert metrics == DUMMY_METRICS
174176

175177

176-
def test_metrics_read_extra_columns(tmpdir: TmpDir) -> None:
178+
def test_metrics_read_extra_columns(tmp_path: Path) -> None:
177179
person = Person(name="Max", age=42)
178-
path = Path(tmpdir) / "metrics.txt"
180+
path = tmp_path / "metrics.txt"
179181
with path.open("w") as writer:
180182
header = Person.header()
181183
header.append("foo")
@@ -188,9 +190,9 @@ def test_metrics_read_extra_columns(tmpdir: TmpDir) -> None:
188190
list(Person.read(path=path, ignore_extra_fields=False))
189191

190192

191-
def test_metrics_read_missing_optional_columns(tmpdir: TmpDir) -> None:
193+
def test_metrics_read_missing_optional_columns(tmp_path: Path) -> None:
192194
person = PersonMaybeAge(name="Max", age=None)
193-
path = Path(tmpdir) / "metrics.txt"
195+
path = tmp_path / "metrics.txt"
194196

195197
# The "age" column is optional, and not in the file, but that's ok
196198
with path.open("w") as writer:
@@ -204,9 +206,9 @@ def test_metrics_read_missing_optional_columns(tmpdir: TmpDir) -> None:
204206
list(PersonMaybeAge.read(path=path))
205207

206208

207-
def test_metric_read_missing_column_with_default(tmpdir: TmpDir) -> None:
209+
def test_metric_read_missing_column_with_default(tmp_path: Path) -> None:
208210
person = PersonDefault(name="Max")
209-
path = Path(tmpdir) / "metrics.txt"
211+
path = tmp_path / "metrics.txt"
210212

211213
# The "age" column hs a default, and not in the file, but that's ok
212214
with path.open("w") as writer:

0 commit comments

Comments
 (0)